@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
package/src/pr-post.ts CHANGED
@@ -32,13 +32,17 @@
32
32
  import { appendFileSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
33
33
  import { tmpdir } from "node:os";
34
34
  import { join } from "node:path";
35
- import { prNoteMarker, prStatusContext, prStatusDescription, prStatusState, renderPrNote, type PrOverdue, type PrReport } from "./pr-loop";
35
+ import { prNoteMarker, prStatusContext, renderPrNote, type PrOverdue, type PrReport } from "./pr-loop";
36
+ import { prStatusDescription, prStatusState } from "./pr-status";
36
37
  import { forgePrincipalOf, type PrForge } from "./pr-forge";
37
- import { GITHUB_COMMENT_LIMIT, GITLAB_NOTE_LIMIT } from "./plan-summary";
38
+ import { fitNote, GITHUB_COMMENT_LIMIT, GITLAB_NOTE_LIMIT } from "./plan-summary";
38
39
  import { activeProductWords, commentLine, type CiProductWords } from "./ci-product-words";
39
40
  import { controlEdgeFactsFromEnv, remarkCrossStackEdges, type ControlEdgeFacts } from "./control/edges";
40
- import { checkEvidenceNoteLine } from "./workspace/trust/check-evidence-report";
41
- import { isPlanNote, planNoteMarker, PR_PLAN_NOTE_CONTRACT, PR_PLAN_NOTE_FILE, renderPlanNote, type PrPlanNoteHandoff, type PrPlanNoteWords } from "./pr-plan-note";
41
+ import { CHECK_EVIDENCE_FILE, checkEvidenceNoteLine, openEvidenceFor } from "./workspace/trust/check-evidence-report";
42
+ import { PLAN_RUN_RECORD_FILE, readPlanRunRecord } from "./pr-plan-record";
43
+ import type { OpRunRecordInput } from "./op/runtime";
44
+ import type { RunOrigin } from "./lifecycle/release-ledger";
45
+ import { isPlanNote, PLAN_BODY_LIMIT, PLAN_SUBJECT_LIMIT, planNoteMarker, planSubjectProblem, PR_PLAN_NOTE_CONTRACT, PR_PLAN_NOTE_FILE, PRODUCT_MARKER_BODY, PRODUCT_MARKER_LIMIT, PRODUCT_MARKER_NAME, productMarkerLine, renderPlanNote, sinceLastLine, type PrPlanBodyHandoff, type PrPlanNoteHandoff, type PrPlanNoteWords, type PrPlanSubject } from "./pr-plan-note";
42
46
 
43
47
  /** The plan report's file under the report directory. */
44
48
  export const PR_PLAN_REPORT_FILE = "pr-plan.json";
@@ -90,6 +94,35 @@ export interface PlanPostInput {
90
94
  * from the pipeline, never from the report.
91
95
  */
92
96
  noteWords?: PrPlanNoteWords;
97
+ /**
98
+ * Notices the note job's own lines wrote (#4931), each added under a
99
+ * product's plan note hand-off's counts, after its own. Default: the
100
+ * lines of the file `CHANT_PLAN_NOTE_NOTICES` names, which the generated
101
+ * note job sets to a file outside the report the plan job handed on.
102
+ */
103
+ notices?: string[];
104
+ /**
105
+ * Keep the plan job's run record (#4899, ./pr-plan-record.ts), when it
106
+ * wrote one into the hand-off: read as data, with `origin` naming the plan
107
+ * job's run, and handed to `keep`, which appends it to the run ledger and
108
+ * pushes. `keep` returns a warning to say, when there is one.
109
+ */
110
+ recordRun?: PlanRunRecorder;
111
+ /**
112
+ * The one argument a re-plan was narrowed to (#4963), such as a
113
+ * terragucci root: when the report or the hand-off says the change
114
+ * reaches nothing, the pull request gets a reply that the argument is not
115
+ * affected, and the note and the status stay as they were. Ignored when
116
+ * empty or not one plain word.
117
+ */
118
+ notAffected?: string;
119
+ }
120
+
121
+ /** How the note job keeps the plan job's run record (#4899). */
122
+ export interface PlanRunRecorder {
123
+ /** The plan job's run, as the note job names it. */
124
+ origin?: RunOrigin;
125
+ keep(record: OpRunRecordInput): Promise<string | undefined>;
93
126
  }
94
127
 
95
128
  /** What {@link postPlanReport} did. */
@@ -100,6 +133,8 @@ export interface PlanPostResult {
100
133
  noted: boolean;
101
134
  /** Why the report was not used, when it was not. */
102
135
  refused?: string;
136
+ /** The id of the plan job's run record kept on chant/lifecycle (#4899), when one was. */
137
+ recorded?: string;
103
138
  warnings: string[];
104
139
  }
105
140
 
@@ -136,7 +171,7 @@ export function readPlanReport(input: Pick<PlanPostInput, "dir" | "pr" | "head"
136
171
  * The note for `report`, rendered here, with every `<!--` after the marker
137
172
  * line written as `&lt;!--`, so the note carries no hidden marker but its own.
138
173
  */
139
- export function planNoteFor(report: PrReport, forge: Pick<PrForge, "kind" | "host">, marker: string, baseTip?: string): string {
174
+ export function planNoteFor(report: PrReport, forge: Pick<PrForge, "kind" | "host">, marker: string, baseTip?: string, own?: string): string {
140
175
  const note = renderPrNote(report, {
141
176
  limit: forge.kind === "gitlab" ? GITLAB_NOTE_LIMIT : GITHUB_COMMENT_LIMIT,
142
177
  approver: forgePrincipalOf(forge.kind, forge.host, "<your-login>"),
@@ -145,7 +180,42 @@ export function planNoteFor(report: PrReport, forge: Pick<PrForge, "kind" | "hos
145
180
  const rest = (at < 0 ? "" : note.slice(at + 1)).split("<!--").join("&lt;!--");
146
181
  // #4628: the tip line is written after the defusing, from the caller's sha, never the report's.
147
182
  const tip = baseTip && SHA.test(baseTip) ? `${rest.endsWith("\n") ? "" : "\n"}${prNoteTipMarker(baseTip)}\n` : "";
148
- return `${marker}\n${rest}${tip}`;
183
+ // #4963: the product's own line, already checked, under chant's marker.
184
+ return `${marker}\n${own ? `${own}\n` : ""}${rest}${tip}`;
185
+ }
186
+
187
+ /**
188
+ * The product's hidden line for a report or a hand-off (#4931, #4963): from
189
+ * the pipeline's `productMarker` and the file's `marker`, checked against
190
+ * {@link PRODUCT_MARKER_BODY}. Undefined when either is missing or the
191
+ * marker is not plain words.
192
+ */
193
+ function productLineOf(name: string | undefined, marker: unknown): string | undefined {
194
+ if (name === undefined || !PRODUCT_MARKER_NAME.test(name) || typeof marker !== "string" || marker.length > PRODUCT_MARKER_LIMIT) return undefined;
195
+ if (marker !== "" && !PRODUCT_MARKER_BODY.test(marker)) return undefined;
196
+ return productMarkerLine(name, marker);
197
+ }
198
+
199
+ /** The one plain word a re-plan was narrowed to (#4963), or undefined. */
200
+ function narrowedTo(input: Pick<PlanPostInput, "notAffected">): string | undefined {
201
+ const a = input.notAffected?.trim();
202
+ return a && /^[A-Za-z0-9_.\/@+=,:-]+$/.test(a) ? a : undefined;
203
+ }
204
+
205
+ /**
206
+ * The reply for a re-plan narrowed to an argument the change does not
207
+ * reach (#4963), in place of the note and the status, as terragucci's
208
+ * plan-note job replied (plan-note.ts).
209
+ */
210
+ async function replyNotAffected(input: PlanPostInput, argument: string, state: PlanPostResult["state"], warnings: string[]): Promise<PlanPostResult> {
211
+ const description = `${argument} is not affected by this pull request, so nothing was planned.`;
212
+ try {
213
+ await input.forge.addComment(input.pr, `${activeProductWords().product}: ${description}`);
214
+ } catch (err) {
215
+ warnings.push(`could not reply on #${input.pr}: ${err instanceof Error ? err.message : String(err)}`);
216
+ }
217
+ const recorded = await keepRunRecord(input, warnings);
218
+ return { state, description: cut(description), noted: false, ...(recorded ? { recorded } : {}), warnings };
149
219
  }
150
220
 
151
221
  /** The hidden line a note carries with the target branch's commit it was posted against (#4628). */
@@ -158,6 +228,55 @@ export function prNoteStaleMarker(sha: string): string {
158
228
  return `<!-- chant-pr-stale:${sha} -->`;
159
229
  }
160
230
 
231
+ /**
232
+ * The hidden line a note keeps its plan's subject in (#4972): base64url of
233
+ * the subject's JSON, `{ id }` alone when its parts would make the line
234
+ * longer than {@link PLAN_SUBJECT_LIMIT}. Undefined when even that is.
235
+ */
236
+ export function prNoteSubjectMarker(subject: PrPlanSubject): string | undefined {
237
+ const line = (s: PrPlanSubject) => `<!-- chant-pr-subject:${Buffer.from(JSON.stringify(s), "utf8").toString("base64url")} -->`;
238
+ const full = line(subject);
239
+ if (full.length <= PLAN_SUBJECT_LIMIT) return full;
240
+ const bare = line({ id: subject.id });
241
+ return bare.length <= PLAN_SUBJECT_LIMIT ? bare : undefined;
242
+ }
243
+
244
+ const SUBJECT_LINE = /^<!-- chant-pr-subject:([A-Za-z0-9_-]+) -->$/m;
245
+
246
+ /**
247
+ * The subject a note kept (#4972), checked again: the line was chant's, but
248
+ * what it holds came from an earlier plan job. Undefined when there is none.
249
+ */
250
+ export function subjectInNote(body: string): PrPlanSubject | undefined {
251
+ const m = SUBJECT_LINE.exec(body.replace(/\r\n/g, "\n"));
252
+ if (!m?.[1] || m[1].length > PLAN_SUBJECT_LIMIT) return undefined;
253
+ try {
254
+ const s = JSON.parse(Buffer.from(m[1], "base64url").toString("utf8")) as unknown;
255
+ return planSubjectProblem(s) === undefined ? (s as PrPlanSubject) : undefined;
256
+ } catch {
257
+ return undefined;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * The line saying what changed since the previous note (#4972): the
263
+ * previous note of the same environment and member is read with the job's
264
+ * token, and its kept subject compared with the hand-off's. Undefined when
265
+ * there is no previous note, it kept no subject, or the id is the same. A
266
+ * forge that refuses the read is a warning.
267
+ */
268
+ async function sinceLastOf(input: PlanPostInput, subject: PrPlanSubject, words: PrPlanNoteWords | undefined, warnings: string[]): Promise<string | undefined> {
269
+ let found: { body: string } | undefined;
270
+ try {
271
+ found = await input.forge.findComment(input.pr, prNoteMarker(input.env, input.member));
272
+ } catch (err) {
273
+ warnings.push(`could not read the previous note on #${input.pr}, so the note does not say what changed since it: ${err instanceof Error ? err.message : String(err)}`);
274
+ return undefined;
275
+ }
276
+ const previous = found ? subjectInNote(found.body) : undefined;
277
+ return previous ? sinceLastLine(previous, subject, words ?? {}) : undefined;
278
+ }
279
+
161
280
  const TIP_LINE = /<!-- chant-pr-tip:([0-9a-f]{40}) -->/;
162
281
  const STALE_LINE = /<!-- chant-pr-stale:([0-9a-f]{40}) -->/;
163
282
  const STALE_PREFIX = "> Stale: ";
@@ -195,6 +314,9 @@ export async function postPlanReport(input: PlanPostInput): Promise<PlanPostResu
195
314
  description = cut(read.refused);
196
315
  } else {
197
316
  let report = read.report;
317
+ // #4963: a re-plan narrowed to an argument the change does not reach.
318
+ const narrowed = narrowedTo(input);
319
+ if (narrowed && report.status === "nothing" && !failedJob) return replyNotAffected(input, narrowed, "success", warnings);
198
320
  if (input.overdue) {
199
321
  const { overdue: _forged, ...rest } = report;
200
322
  const found = await input.overdue().catch(() => [] as PrOverdue[]);
@@ -209,7 +331,9 @@ export async function postPlanReport(input: PlanPostInput): Promise<PlanPostResu
209
331
  state = prStatusState(report);
210
332
  description = prStatusDescription(report);
211
333
  // A member the change does not reach has nothing to say on the pull request (as pr-plan's own publish).
212
- if (!(input.member && report.status === "nothing" && !report.overdue?.length && !report.migrations?.length)) note = planNoteFor(report, input.forge, prNoteMarker(input.env, input.member), input.baseTip);
334
+ // #4963: the report's own `marker`, under the pipeline's productMarker, as a hand-off's.
335
+ const own = productLineOf((input.noteWords ?? noteWordsFromEnv())?.productMarker, (read.report as { marker?: unknown }).marker);
336
+ if (!(input.member && report.status === "nothing" && !report.overdue?.length && !report.migrations?.length)) note = planNoteFor(report, input.forge, prNoteMarker(input.env, input.member), input.baseTip, own);
213
337
  } catch (err) {
214
338
  refused = `the plan report does not render: ${err instanceof Error ? err.message : String(err)}`;
215
339
  state = "failure";
@@ -229,7 +353,40 @@ export async function postPlanReport(input: PlanPostInput): Promise<PlanPostResu
229
353
  warnings.push(`the description check did not run: ${err instanceof Error ? err.message : String(err)}`);
230
354
  }
231
355
  }
232
- return { state, description: cut(description), noted: note !== undefined, ...(refused ? { refused } : {}), warnings };
356
+ const recorded = await keepRunRecord(input, warnings);
357
+ return { state, description: cut(description), noted: note !== undefined, ...(refused ? { refused } : {}), ...(recorded ? { recorded } : {}), warnings };
358
+ }
359
+
360
+ /**
361
+ * Keep the plan job's run record on chant/lifecycle (#4899), with
362
+ * `input.recordRun`. A record that is missing, refused or not kept is a
363
+ * warning: the note and the status stand. Returns the record's id once kept.
364
+ */
365
+ async function keepRunRecord(input: PlanPostInput, warnings: string[]): Promise<string | undefined> {
366
+ if (!input.recordRun) return undefined;
367
+ const read = readPlanRunRecord(input.dir, {
368
+ env: input.env,
369
+ head: input.head,
370
+ ...(input.member ? { target: input.member } : {}),
371
+ ...(input.result ? { result: input.result } : {}),
372
+ ...(input.recordRun.origin ? { origin: input.recordRun.origin } : {}),
373
+ });
374
+ if (!read) {
375
+ warnings.push("the plan job wrote no run record, so none is kept");
376
+ return undefined;
377
+ }
378
+ if ("refused" in read) {
379
+ warnings.push(`the plan job's run record was not kept: ${read.refused}`);
380
+ return undefined;
381
+ }
382
+ try {
383
+ const said = await input.recordRun.keep(read.record);
384
+ if (said) warnings.push(said);
385
+ return read.record.id;
386
+ } catch (err) {
387
+ warnings.push(`the plan job's run record was not kept on chant/lifecycle: ${err instanceof Error ? err.message : String(err)}`);
388
+ return undefined;
389
+ }
233
390
  }
234
391
 
235
392
  /**
@@ -277,7 +434,7 @@ async function postOutcome(
277
434
  * Read a product's plan note hand-off under `dir` (#4799) and check it is the
278
435
  * one the caller ran, as {@link readPlanReport} checks a report.
279
436
  */
280
- export function readPlanNoteHandoff(input: Pick<PlanPostInput, "dir" | "pr" | "head" | "env" | "member">): { handoff: PrPlanNoteHandoff } | { refused: string } {
437
+ export function readPlanNoteHandoff(input: Pick<PlanPostInput, "dir" | "pr" | "head" | "env" | "member">): { handoff: PrPlanNoteHandoff | PrPlanBodyHandoff } | { refused: string } {
281
438
  let doc: unknown;
282
439
  try {
283
440
  doc = JSON.parse(readFileSync(join(input.dir, PR_PLAN_NOTE_FILE), "utf-8"));
@@ -294,10 +451,50 @@ export function readPlanNoteHandoff(input: Pick<PlanPostInput, "dir" | "pr" | "h
294
451
  if ((r.member ?? undefined) !== input.member) return { refused: `the plan note is for ${JSON.stringify(r.member ?? null)}, not ${JSON.stringify(input.member ?? null)}` };
295
452
  if (r.state !== "success" && r.state !== "failure" && r.state !== "pending") return { refused: `the plan note's state ${JSON.stringify(r.state)} is not success, failure or pending` };
296
453
  if (typeof r.description !== "string") return { refused: "the plan note has no description" };
297
- if (!isPlanNote(r.note) || r.note.head !== r.head || !Array.isArray(r.note.waves) || !Array.isArray(r.note.groups) || !Array.isArray(r.note.named)) {
454
+ // #4963: the product's own text in place of a plan note.
455
+ if (r.body !== undefined) {
456
+ if (r.note !== undefined) return { refused: "the plan note gives both a note and a body; give one" };
457
+ if (typeof r.body !== "string" || r.body.length > PLAN_BODY_LIMIT) return { refused: `the plan note's body is not text of at most ${PLAN_BODY_LIMIT} characters` };
458
+ } else if (!isPlanNote(r.note) || r.note.head !== r.head || !Array.isArray(r.note.waves) || !Array.isArray(r.note.groups) || !Array.isArray(r.note.named)) {
298
459
  return { refused: "the plan note's note is not a plan note for its head" };
299
460
  }
300
- return { handoff: doc as PrPlanNoteHandoff };
461
+ // #4931: the product's hidden line is the change's too, so it holds only plain words.
462
+ if (r.marker !== undefined && (typeof r.marker !== "string" || r.marker.length > PRODUCT_MARKER_LIMIT || (r.marker !== "" && !PRODUCT_MARKER_BODY.test(r.marker)))) {
463
+ return { refused: `the plan note's marker is not words of letters, digits and _.,/@+=:- of at most ${PRODUCT_MARKER_LIMIT} characters` };
464
+ }
465
+ // #4972: the subject is kept in the note and said back in a later one, so it holds only plain words too.
466
+ const subjectProblem = r.subject !== undefined ? planSubjectProblem(r.subject) : undefined;
467
+ if (subjectProblem) return { refused: `the plan note's subject ${subjectProblem}` };
468
+ return { handoff: doc as PrPlanNoteHandoff | PrPlanBodyHandoff };
469
+ }
470
+
471
+ /**
472
+ * The note for a hand-off of the product's own text (#4963): chant's
473
+ * marker, the product's line, the body with every `<!--` defused, the
474
+ * notices as quoted lines under it, the tip line, cut to the forge's limit.
475
+ */
476
+ export function planBodyHandoffNote(handoff: PrPlanBodyHandoff, forge: Pick<PrForge, "kind">, marker: string, noteWords?: PrPlanNoteWords, baseTip?: string, notices: readonly string[] = []): string {
477
+ const limit = forge.kind === "gitlab" ? GITLAB_NOTE_LIMIT : GITHUB_COMMENT_LIMIT;
478
+ const line = productLineOf(noteWords?.productMarker, handoff.marker);
479
+ const head = `${marker}\n${line ? `${line}\n` : ""}`;
480
+ const said = notices.length > 0 ? `\n${notices.map((n) => `> ${n.split("<!--").join("&lt;!--")}`).join("\n")}\n` : "";
481
+ const tip = baseTip && SHA.test(baseTip) ? `${prNoteTipMarker(baseTip)}\n` : "";
482
+ // #4972: the subject, kept for the next note to compare with.
483
+ const kept = handoff.subject ? prNoteSubjectMarker(handoff.subject) : undefined;
484
+ const subject = kept ? `${kept}\n` : "";
485
+ const body = handoff.body.split("<!--").join("&lt;!--").replace(/\n*$/, "\n");
486
+ return `${head}${fitNote(body, { limit: Math.max(0, limit - head.length - said.length - tip.length - subject.length) })}${said}${tip}${subject}`;
487
+ }
488
+
489
+ /** The notices in the file `CHANT_PLAN_NOTE_NOTICES` names (#4931), one a line, or none when unset or unreadable. */
490
+ export function noticesFromEnv(env: NodeJS.ProcessEnv = process.env): string[] {
491
+ const file = env.CHANT_PLAN_NOTE_NOTICES;
492
+ if (!file || !existsSync(file)) return [];
493
+ try {
494
+ return readFileSync(file, "utf-8").split("\n").map((l) => l.trim()).filter((l) => l !== "");
495
+ } catch {
496
+ return [];
497
+ }
301
498
  }
302
499
 
303
500
  /** The note words from `CHANT_PLAN_NOTE_WORDS` (#4799), or undefined when unset or not an object. */
@@ -320,14 +517,21 @@ function noteWordsFromEnv(): PrPlanNoteWords | undefined {
320
517
  */
321
518
  export function planNoteHandoffNote(handoff: PrPlanNoteHandoff, forge: Pick<PrForge, "kind">, marker: string, noteWords?: PrPlanNoteWords, baseTip?: string): string {
322
519
  const words = activeProductWords();
323
- const rendered = renderPlanNote(handoff.note, { limit: forge.kind === "gitlab" ? GITLAB_NOTE_LIMIT : GITHUB_COMMENT_LIMIT, words, ...(noteWords ? { note: noteWords } : {}) });
520
+ // #4972: the subject, kept for the next note to compare with, within the forge's limit.
521
+ const kept = handoff.subject ? prNoteSubjectMarker(handoff.subject) : undefined;
522
+ const limit = (forge.kind === "gitlab" ? GITLAB_NOTE_LIMIT : GITHUB_COMMENT_LIMIT) - (kept ? kept.length + 1 : 0);
523
+ const rendered = renderPlanNote(handoff.note, { limit, words, ...(noteWords ? { note: noteWords } : {}) });
324
524
  let body = rendered.split("<!--").join("&lt;!--");
325
525
  const n = handoff.note;
326
526
  const previews = n.previews ?? [];
327
527
  const waves = planNoteMarker(noteWords?.marker ?? `${words.product}:waves`, { head: n.head, waves: n.waves.map((x) => ({ number: x.number, digest: x.digest ?? null, waits: x.waits === true })), ...(previews.length ? { previews } : {}) });
328
528
  body = body.replace(`&lt;!--${waves.slice(4)}`, waves);
329
529
  const tip = baseTip && SHA.test(baseTip) ? `${body.endsWith("\n") ? "" : "\n"}${prNoteTipMarker(baseTip)}\n` : "";
330
- return `${marker}\n${body}${tip}`;
530
+ // #4931: the product's own line, from the pipeline's name and the hand-off's checked body, under chant's marker.
531
+ const name = noteWords?.productMarker;
532
+ const own = name !== undefined && PRODUCT_MARKER_NAME.test(name) && handoff.marker !== undefined ? `${productMarkerLine(name, handoff.marker)}\n` : "";
533
+ const subject = kept ? `${body.endsWith("\n") || tip ? "" : "\n"}${kept}\n` : "";
534
+ return `${marker}\n${own}${body}${tip}${subject}`;
331
535
  }
332
536
 
333
537
  /** {@link postPlanReport} for a product's plan note hand-off (#4799). */
@@ -347,8 +551,22 @@ async function postPlanNoteHandoff(input: PlanPostInput): Promise<PlanPostResult
347
551
  } else {
348
552
  state = read.handoff.state;
349
553
  description = read.handoff.description;
554
+ const h = read.handoff;
555
+ // #4963: a re-plan narrowed to an argument the change does not reach.
556
+ const narrowed = narrowedTo(input);
557
+ if (narrowed && "note" in h && h.note.nothing === true && !failedJob) return replyNotAffected(input, narrowed, state, warnings);
558
+ // #4931: the overdue Ops (#4289), asked here with the job's token, and the note job's own notices, under the counts.
559
+ const given = "note" in h ? (h.note.notices ?? []) : [];
560
+ // An Op the product's own notices already call overdue is not said twice.
561
+ const overdue = input.overdue ? (await input.overdue().catch(() => [] as PrOverdue[])).filter((o) => !given.some((g) => g.includes(`\`${o.op}\``) && g.includes("overdue"))).map((o) => o.message) : [];
562
+ const noteWords = input.noteWords ?? noteWordsFromEnv();
563
+ // #4972: what changed since the previous note, from the subject it kept, read here with the job's token.
564
+ const since = h.subject ? await sinceLastOf(input, h.subject, noteWords, warnings) : undefined;
565
+ const added = [...(since ? [since] : []), ...overdue, ...(input.notices ?? noticesFromEnv())].filter((n, i, all) => !given.includes(n) && all.indexOf(n) === i);
350
566
  try {
351
- note = planNoteHandoffNote(read.handoff, input.forge, prNoteMarker(input.env, input.member), input.noteWords ?? noteWordsFromEnv(), input.baseTip);
567
+ note = "note" in h
568
+ ? planNoteHandoffNote(added.length > 0 ? { ...h, note: { ...h.note, notices: [...given, ...added] } } : h, input.forge, prNoteMarker(input.env, input.member), noteWords, input.baseTip)
569
+ : planBodyHandoffNote(h, input.forge, prNoteMarker(input.env, input.member), noteWords, input.baseTip, added);
352
570
  } catch (err) {
353
571
  refused = `the plan note does not render: ${err instanceof Error ? err.message : String(err)}`;
354
572
  state = "failure";
@@ -360,7 +578,8 @@ async function postPlanNoteHandoff(input: PlanPostInput): Promise<PlanPostResult
360
578
  }
361
579
  }
362
580
  note = await postOutcome(input, context, state, description, note, refused, warnings);
363
- return { state, description: cut(description), noted: note !== undefined, ...(refused ? { refused } : {}), warnings };
581
+ const recorded = await keepRunRecord(input, warnings);
582
+ return { state, description: cut(description), noted: note !== undefined, ...(refused ? { refused } : {}), ...(recorded ? { recorded } : {}), warnings };
364
583
  }
365
584
 
366
585
  /**
@@ -398,6 +617,17 @@ export interface OpenPlanPostInput {
398
617
  description?: (report: PrReport) => Promise<void>;
399
618
  /** The target branch's commit this pipeline runs at (#4628), for each note's tip line. */
400
619
  baseTip?: string;
620
+ /**
621
+ * Keep each plan job's run record (#4899) from its artifacts, the job
622
+ * named as its run origin's `jobId`. `repo` is the project's path.
623
+ */
624
+ recordRun?: { repo?: string; keep: PlanRunRecorder["keep"] };
625
+ /**
626
+ * Where the signing job of this pipeline kept each merge request's
627
+ * `evidence.json` (#4914), `<dir>/<iid>/evidence.json`: the note of a
628
+ * merge request whose file names its head ends with the checks line.
629
+ */
630
+ evidenceDir?: string;
401
631
  }
402
632
 
403
633
  /** What {@link postOpenPlanReports} did for one merge request. */
@@ -447,6 +677,12 @@ export async function postOpenPlanReports(input: OpenPlanPostInput): Promise<{ p
447
677
  // #4799: a product's plan verb writes its plan note hand-off in place of the report.
448
678
  const handoff = text === undefined ? await forge.jobArtifact(job.id, `${input.artifactDir.replace(/\/+$/, "")}/${PR_PLAN_NOTE_FILE}`) : undefined;
449
679
  if (handoff !== undefined) writeFileSync(join(dir, PR_PLAN_NOTE_FILE), handoff);
680
+ // #4899: the plan job's run record, kept with its note.
681
+ const runRecord = input.recordRun ? await forge.jobArtifact(job.id, `${input.artifactDir.replace(/\/+$/, "")}/${PLAN_RUN_RECORD_FILE}`) : undefined;
682
+ if (runRecord !== undefined) writeFileSync(join(dir, PLAN_RUN_RECORD_FILE), runRecord);
683
+ // #4914: what the signing job signed for this head, which the note's checks line says.
684
+ const evidence = input.evidenceDir ? openEvidenceFor(input.evidenceDir, job.pr, job.head) : undefined;
685
+ if (evidence !== undefined) writeFileSync(join(dir, CHECK_EVIDENCE_FILE), evidence);
450
686
  const posted = await postPlanReport({
451
687
  // The status links to the plan job it reports on, which is how the next run knows it is posted.
452
688
  forge: job.url ? { ...forge, runUrl: job.url } : forge,
@@ -459,6 +695,9 @@ export async function postOpenPlanReports(input: OpenPlanPostInput): Promise<{ p
459
695
  ...(overdueOnce ? { overdue: overdueOnce } : {}),
460
696
  ...(input.description ? { description: input.description } : {}),
461
697
  ...(input.baseTip ? { baseTip: input.baseTip } : {}),
698
+ ...(input.recordRun
699
+ ? { recordRun: { origin: { forge: "gitlab", ...(input.recordRun.repo ? { repo: input.recordRun.repo } : {}), ...(job.url ? { url: job.url } : {}), jobId: String(job.id) }, keep: input.recordRun.keep } }
700
+ : {}),
462
701
  });
463
702
  posts.push({ pr: job.pr, head: job.head, posted });
464
703
  } finally {
@@ -129,6 +129,20 @@ describe("github", () => {
129
129
  const f = forge({ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [] }, [`GET ${repo}/commits/${HEAD}/check-runs`]: { check_runs: [] } });
130
130
  expect(await f.prChecksPassed!(7, HEAD)).toMatchObject({ passed: false, pending: true });
131
131
  });
132
+
133
+ test("checks: a required status that has not reported is pending, through checkPrRequires' require (#4913)", async () => {
134
+ const green = { [`GET ${repo}/commits/${HEAD}/check-runs`]: { check_runs: [{ name: "lint", status: "completed", conclusion: "success" }] } };
135
+ const before = forge({ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [{ context: "ci/test", state: "success" }] }, ...green });
136
+ expect(await before.prChecksPassed!(7, HEAD, [], ["chant/ref-gate"])).toEqual({ passed: false, pending: true, reason: "chant/ref-gate still running on aaaaaaaa" });
137
+ const out = await checkPrRequires(before, 7, HEAD, { only: ["checks"], require: ["chant/ref-gate"], wait: async () => {} });
138
+ expect(out.find((o) => o.name === "checks")).toMatchObject({ passed: false, pending: true, reason: "chant/ref-gate still running on aaaaaaaa" });
139
+ // Without require, the same head passes: the gap the ref gate's status job leaves until it posts.
140
+ expect((await before.prChecksPassed!(7, HEAD)).passed).toBe(true);
141
+ const after = forge({ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [{ context: "ci/test", state: "success" }, { context: "chant/ref-gate", state: "success" }] }, ...green });
142
+ expect(await after.prChecksPassed!(7, HEAD, [], ["chant/ref-gate"])).toEqual({ passed: true, reason: "3 checks passed on aaaaaaaa" });
143
+ const refused = forge({ [`GET ${repo}/commits/${HEAD}/status`]: { statuses: [{ context: "chant/ref-gate", state: "failure" }] }, ...green });
144
+ expect((await refused.prChecksPassed!(7, HEAD, [], ["chant/ref-gate"])).reason).toBe("chant/ref-gate failed on aaaaaaaa");
145
+ });
132
146
  });
133
147
 
134
148
  describe("forgejo", () => {
@@ -264,6 +278,12 @@ describe("gitlab", () => {
264
278
  expect(await f.prChecksPassed!(3, HEAD, ["apply"])).toEqual({ passed: true, reason: "2 checks passed on aaaaaaaa" });
265
279
  expect((await f.prChecksPassed!(3, HEAD)).pending).toBe(true);
266
280
  });
281
+
282
+ test("checks: a required status that has not reported is pending (#4913)", async () => {
283
+ const f = (statuses: unknown[]) => forge({ [`GET ${project}/repository/commits/${HEAD}/statuses`]: statuses });
284
+ expect(await f([{ id: 1, name: "test", status: "success" }]).prChecksPassed!(3, HEAD, [], ["chant/ref-gate"])).toEqual({ passed: false, pending: true, reason: "chant/ref-gate still running on aaaaaaaa" });
285
+ expect((await f([{ id: 1, name: "test", status: "success" }, { id: 2, name: "chant/ref-gate", status: "success" }]).prChecksPassed!(3, HEAD, [], ["chant/ref-gate"])).passed).toBe(true);
286
+ });
267
287
  });
268
288
 
269
289
  describe("checkPrRequires", () => {
@@ -16,6 +16,9 @@
16
16
  */
17
17
  import type { PrApproverFilter, PrExcludedApprover, PrForge, PrRequireResult } from "./pr-forge";
18
18
 
19
+ /** `require` in {@link PrRequiresOptions} (#4913). */
20
+ export { REF_GATE_PIECES_FLOOR } from "./release-floors";
21
+
19
22
  /** The four checks, in the order they run and the report lists them. */
20
23
  export const PR_APPLY_REQUIRES = ["approved", "mergeable", "undiverged", "checks"] as const;
21
24
 
@@ -40,6 +43,12 @@ export interface PrRequiresOptions {
40
43
  approvers?: PrApproverFilter;
41
44
  /** Status names the `checks` require leaves out: the apply's own. */
42
45
  ignore?: readonly string[];
46
+ /**
47
+ * Statuses the `checks` require needs to have reported and passed (#4913),
48
+ * such as the ref gate's: `refGateRulesAt(...).status` from
49
+ * `@intentius/chant/ref-gate-rules`. One not reported yet is pending.
50
+ */
51
+ require?: readonly string[];
43
52
  /** How many times a pending check is asked in all. Default 5. */
44
53
  reads?: number;
45
54
  /** The wait between reads. Default 3 seconds. */
@@ -61,7 +70,7 @@ export async function checkPrRequires(forge: PrForge, pr: number, head: string,
61
70
  approved: forge.prApproved ? () => forge.prApproved!(pr, head, opts.approvers) : undefined,
62
71
  mergeable: forge.prMergeable ? () => forge.prMergeable!(pr, head) : undefined,
63
72
  undiverged: forge.prUndiverged ? () => forge.prUndiverged!(pr, head) : undefined,
64
- checks: forge.prChecksPassed ? () => forge.prChecksPassed!(pr, head, opts.ignore ?? []) : undefined,
73
+ checks: forge.prChecksPassed ? () => forge.prChecksPassed!(pr, head, opts.ignore ?? [], opts.require ?? []) : undefined,
65
74
  };
66
75
  const out: PrRequireOutcome[] = [];
67
76
  const asked = new Set<PrApplyRequire>(opts.only ?? PR_APPLY_REQUIRES);
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The pull-request loop's commit status (#3183): its description and its
3
+ * state, from the report `chant components pr-plan` and `pr-apply` write.
4
+ *
5
+ * They lived in `./pr-loop.ts` until #4966 moved them here, so the bundle
6
+ * a product builds from `pr-loop.ts` and `pr-forge.ts` (the report, the note
7
+ * and the forge clients, `pr-loop-bundle.test.ts`) keeps room under its
8
+ * ceiling. chant's own handlers post the status; no product reads these.
9
+ */
10
+
11
+ import { activeProductWords, type CiProductWords } from "./ci-product-words";
12
+ import { memberHoleReasons, type PrReport } from "./pr-loop";
13
+
14
+ /** A commit status's description, at most 140 characters (GitHub's limit). */
15
+ export function prStatusDescription(report: PrReport, words: CiProductWords = activeProductWords()): string {
16
+ const n = report.members.length;
17
+ const many = (k: number): string => `${k} ${words.noun[k === 1 ? 0 : 1]}`;
18
+ const sum = report.members.reduce(
19
+ (acc, m) => ({ change: acc.change + m.counts.create + m.counts.update + m.counts.replace, destroy: acc.destroy + m.counts.delete + m.counts.replace }),
20
+ { change: 0, destroy: 0 },
21
+ );
22
+ const digest = report.digest ? `; plan ${report.digest.replace(/^(?:jcs1-)?sha256:/, "").slice(0, 12)}` : "";
23
+ let text: string;
24
+ switch (report.status) {
25
+ case "nothing":
26
+ text = "nothing to plan";
27
+ break;
28
+ case "planned": {
29
+ const unknown = report.members.filter((m) => memberHoleReasons(report, m.member).length > 0).length;
30
+ // #4626: a narrowed plan says so in its status.
31
+ const narrowed = Object.values(report.narrowed ?? {}).filter((a) => a.length > 0).length;
32
+ text = `${many(n)}${narrowed > 0 ? ` (${narrowed} narrowed with --target)` : ""}: ${sum.change} to change, ${sum.destroy} to destroy or replace${unknown > 0 ? `, ${unknown} with holes` : ""}${digest}`;
33
+ break;
34
+ }
35
+ case "plan-failed":
36
+ text = `a ${words.noun[0]} failed to ${words.verbs.plan[0]}${digest}`;
37
+ break;
38
+ case "recorded":
39
+ text = `recorded ${many(n)}: ${report.approval.status === "approved" ? "the approved plan" : report.approval.status === "changed" ? "the plan differs from the approved one" : "no approval for this plan"}${digest}`;
40
+ break;
41
+ case "applied":
42
+ text = `${words.verbs.apply[1]} ${many(n)}${digest}`;
43
+ break;
44
+ case "wave-applied": {
45
+ const last = (report.waves ?? []).filter((w) => w.status === "applied").at(-1);
46
+ text = `applied wave ${last?.wave ?? "?"} of ${report.selection.waves.length}${last ? ` under ${last.approval === "pull-request" ? "the pull request's approval" : `${last.gate}`}` : ""}`;
47
+ break;
48
+ }
49
+ case "failed":
50
+ text = `apply failed for ${report.members.filter((m) => m.status === "failed").map((m) => m.member).join(", ")}`;
51
+ break;
52
+ case "waiting":
53
+ text = `waiting: ${report.members.filter((m) => m.status === "waiting").map((m) => m.member).join(", ")} planned again after an upstream applied, not approved yet`;
54
+ break;
55
+ case "refused": {
56
+ const waiting = report.waves?.find((w) => w.status === "waiting");
57
+ if (waiting && (report.refusal === "wave-not-approved" || report.refusal === "wave-plan-changed")) {
58
+ text = `wave ${waiting.wave} waits at ${waiting.gate}: ${report.refusal === "wave-plan-changed" ? "its plan changed after its approval" : "its plan moved, approve it"}`;
59
+ break;
60
+ }
61
+ if (report.refusal === "earlier-wave") {
62
+ text = "refused: an earlier wave has not applied";
63
+ break;
64
+ }
65
+ if (report.refusal === "requires-unmet" || report.refusal === "before-merge-off") {
66
+ const unmet = (report.beforeMerge?.requires ?? []).filter((r) => !r.passed).map((r) => r.name);
67
+ text = report.refusal === "before-merge-off" ? "refused: this workspace does not apply before merge" : `refused: ${unmet.join(", ") || "a require"} unmet for an apply before merge`;
68
+ break;
69
+ }
70
+ if (report.refusal === "policy-denied" || report.refusal === "policy-error") {
71
+ text = report.refusal === "policy-denied" ? `refused: the policy denied the plan (${(report.policy?.rules ?? []).join(", ")})` : "refused: the policy could not be checked";
72
+ break;
73
+ }
74
+ text = `refused: ${report.refusal === "plan-changed" ? "the plan changed after review" : report.refusal === "not-a-reviewer" ? "the approver has not approved the pull request" : report.refusal === "author-approved" ? "the approver wrote the change" : report.refusal === "no-pull-request" ? "no pull request merged this commit" : report.refusal === "locked" ? "another pull request holds a target lock" : "the plan is not approved"}`;
75
+ break;
76
+ }
77
+ }
78
+ return text.length > 140 ? text.slice(0, 137) + "..." : text;
79
+ }
80
+
81
+ /** The commit status state for a report: success, failure, or pending while it waits on approval. */
82
+ export function prStatusState(report: PrReport): "success" | "failure" | "pending" {
83
+ // #4168 decision 1: a merge whose plan differs from the approved one is recorded, and its status fails.
84
+ if (report.status === "recorded") return report.approval.status === "changed" ? "failure" : "success";
85
+ // #4294: a plan the policy denied, with no override, or one it could not check, fails at the plan stage as it would at the apply.
86
+ if (report.status === "planned" && report.policy && (report.policy.result === "error" || (report.policy.result === "denied" && !report.policy.override))) return "failure";
87
+ if (report.status === "planned" || report.status === "applied" || report.status === "wave-applied" || report.status === "nothing") return "success";
88
+ if (report.status === "refused" && (report.refusal === "not-approved" || report.refusal === "wave-not-approved")) return "pending";
89
+ if (report.status === "waiting") return "pending";
90
+ return "failure";
91
+ }