@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,220 @@
1
+ /**
2
+ * #4913: the ref gate's pieces a product uses without code of its own. The
3
+ * rules read at base (`@intentius/chant/ref-gate-rules`), the status a forge
4
+ * check requires, the init pieces that write `.chant/trust.json`, the hook
5
+ * and the runner key hint (`@intentius/chant/ref-gate-init`), and a
6
+ * pre-receive refusal that prints the command recording the request for an
7
+ * override from the checkout.
8
+ */
9
+
10
+ import { existsSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ import { describe, expect, test } from "vitest";
13
+ import { beforeMergeBranch, beforeMergeRefGate } from "../../cli/handlers/pr";
14
+ import { refGateInitChecks, refGateInitPlan, RefGateInitError, writeRefGateInit } from "../../ref-gate-init";
15
+ import { productPlanEvidenceChecks, targetEvidenceCheck } from "../../ci-evidence-jobs";
16
+ import { REF_GATE_STATUS, refGateRulesAt, refGateStatusFor } from "../../ref-gate-rules";
17
+ import { decideRefUpdate, describeDecision, requestCommand } from "./ref-gate";
18
+ import { REF_GATE_HOOK_MARK } from "./ref-gate-cli";
19
+ import { GateRepos, RUNNER, runnerKey, trustJson } from "./ref-gate-fixture";
20
+
21
+ const CHECKS = [
22
+ { check: "plan", command: "chant ci run plan" },
23
+ { check: "lint", action: "warn" as const, command: "npm run lint" },
24
+ ];
25
+
26
+ describe("the ref gate's rules as a library (#4913)", () => {
27
+ test("rules for a ref come from the policy at base, and a change that drops them does not count", () => {
28
+ const r = new GateRepos("4913-rules");
29
+ const ci = runnerKey();
30
+ r.write(".chant/trust.json", trustJson(ci, CHECKS, {}));
31
+ const base = r.commit("policy");
32
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1 }));
33
+ r.commit("drop the rules");
34
+
35
+ const atBase = refGateRulesAt(r.work, { ref: "refs/heads/main", base });
36
+ expect(atBase).toEqual({
37
+ ref: "refs/heads/main",
38
+ base,
39
+ matched: true,
40
+ status: REF_GATE_STATUS,
41
+ checks: [
42
+ { check: "plan", action: "block", command: "chant ci run plan" },
43
+ { check: "lint", action: "warn", command: "npm run lint" },
44
+ ],
45
+ problems: [],
46
+ });
47
+ expect(refGateRulesAt(r.work, { ref: "refs/heads/release/2", base }).matched).toBe(true);
48
+ expect(refGateRulesAt(r.work, { ref: "refs/heads/feature", base })).toMatchObject({ matched: false, status: null, checks: [], problems: [] });
49
+ // At the change itself the rules are gone, which is why a product reads them at base.
50
+ expect(refGateRulesAt(r.work, { ref: "refs/heads/main", base: "HEAD" }).matched).toBe(false);
51
+ });
52
+
53
+ test("a base that names no commit, or a policy that can't be read, is a problem", () => {
54
+ const r = new GateRepos("4913-problems");
55
+ r.write(".chant/trust.json", "{ not json");
56
+ const base = r.commit("broken policy");
57
+ expect(refGateRulesAt(r.work, { ref: "refs/heads/main", base: "nope" }).problems[0]).toContain("--base nope names no commit");
58
+ const broken = refGateRulesAt(r.work, { ref: "refs/heads/main", base });
59
+ expect(broken.matched).toBe(false);
60
+ expect(broken.problems[0]).toContain(".chant/trust.json is not JSON");
61
+ });
62
+
63
+ test("the status a forge check requires: the policy's own name, at origin/<default> when the checkout has it", () => {
64
+ const r = new GateRepos("4913-status");
65
+ const ci = runnerKey();
66
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1, runners: [{ principal: RUNNER, class: "runner", key: ci.pub }], refs: [{ ref: "refs/heads/main", checks: CHECKS, status: "acme/gate" }] }));
67
+ r.commit("policy");
68
+ r.push("main");
69
+ r.git(["fetch", "-q", "origin"]);
70
+ // A local change that drops the rule does not move what the forge's default branch requires.
71
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1 }));
72
+ r.commit("drop locally");
73
+ expect(refGateStatusFor(r.work, "main")).toEqual({ status: "acme/gate" });
74
+ expect(refGateStatusFor(r.work, "trunk").note).toContain("matches refs/heads/trunk, so the ref-gate job sets no status there");
75
+ const bare = new GateRepos("4913-status-head");
76
+ bare.write(".chant/trust.json", "[]");
77
+ bare.commit("not a policy");
78
+ expect(refGateStatusFor(bare.work, "main").problem).toContain("the trust policy can't be read");
79
+ });
80
+ });
81
+
82
+ describe("an apply before merge waits for the ref gate's status (#4966)", () => {
83
+ test("the target branch: --branch, the pull request's target, then the branch the job runs on", () => {
84
+ expect(beforeMergeBranch("release/2", { GITHUB_REF_NAME: "main" })).toBe("release/2");
85
+ expect(beforeMergeBranch(undefined, { GITHUB_BASE_REF: "trunk", GITHUB_REF_NAME: "7/merge" })).toBe("trunk");
86
+ expect(beforeMergeBranch(undefined, { CI_COMMIT_BRANCH: "main" })).toBe("main");
87
+ expect(beforeMergeBranch(undefined, { GITHUB_REF_NAME: "main" })).toBe("main");
88
+ expect(beforeMergeBranch(" ", {})).toBeUndefined();
89
+ });
90
+
91
+ test("the status the policy at base sets for the target branch is required, and none without a rule", async () => {
92
+ const r = new GateRepos("4966-before-merge");
93
+ const ci = runnerKey();
94
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1, runners: [{ principal: RUNNER, class: "runner", key: ci.pub }], refs: [{ ref: "refs/heads/main", checks: CHECKS, status: "acme/gate" }] }));
95
+ const base = r.commit("policy");
96
+ expect(await beforeMergeRefGate(r.work, base, undefined, { GITHUB_REF_NAME: "main" })).toMatchObject({ require: ["acme/gate"] });
97
+ expect(await beforeMergeRefGate(r.work, base, "feature", {})).toEqual({ require: [] });
98
+ expect(await beforeMergeRefGate(r.work, base, undefined, {})).toMatchObject({ require: [], note: expect.stringContaining("names no target branch") });
99
+ r.write(".chant/trust.json", "{ not json");
100
+ const broken = r.commit("broken policy");
101
+ const refused = await beforeMergeRefGate(r.work, broken, "main", {});
102
+ expect("problem" in refused && refused.problem).toContain("the trust policy at base can't be read");
103
+ });
104
+ });
105
+
106
+ describe("the ref gate's init pieces (#4913)", () => {
107
+ test("a checkout with no trust policy gets one with the rule, the pre-push hook and the runner key hint", () => {
108
+ const r = new GateRepos("4913-init-new");
109
+ r.write("README.md", "hi\n");
110
+ r.commit("start");
111
+ const plan = refGateInitPlan(r.work, { checks: CHECKS, chant: "npx chant", runner: "ci:acme/infra", runnerKeySecret: "CHANT_RUNNER_KEY" });
112
+ const trust = plan.files.find((f) => f.path.endsWith(".chant/trust.json"))!;
113
+ expect(trust.status).toBe("created");
114
+ expect(JSON.parse(trust.content)).toEqual({ schema: 1, refs: [{ ref: "refs/heads/main", checks: [{ check: "plan", command: "chant ci run plan" }, { check: "lint", action: "warn", command: "npm run lint" }] }] });
115
+ const hook = plan.files.find((f) => f.path.endsWith("pre-push"))!;
116
+ expect(hook).toMatchObject({ status: "created", mode: 0o755, local: true });
117
+ expect(hook.path.startsWith(join(realpathSync(r.work), ".git"))).toBe(true);
118
+ expect(hook.content).toContain(REF_GATE_HOOK_MARK);
119
+ expect(hook.content).toContain("exec npx chant workspace ref-gate pre-push");
120
+ const hint = plan.notes.find((n) => n.includes("no runner key"))!;
121
+ expect(hint).toContain("chant workspace trust runner add ci:acme/infra --key runner.pem");
122
+ expect(hint).toContain("the CHANT_RUNNER_KEY secret");
123
+ expect(plan.notes.some((n) => n.includes("protected write"))).toBe(true);
124
+
125
+ writeRefGateInit(plan);
126
+ expect(statSync(hook.path).mode & 0o777).toBe(0o755);
127
+ const base = r.commit("ref gate");
128
+ // What init wrote is what the gate reads.
129
+ expect(refGateRulesAt(r.work, { ref: "refs/heads/main", base })).toMatchObject({ matched: true, status: REF_GATE_STATUS, checks: [{ check: "plan", action: "block" }, { check: "lint", action: "warn" }] });
130
+ const again = refGateInitPlan(r.work, { checks: CHECKS, chant: "npx chant" });
131
+ expect(again.files.map((f) => f.status)).toEqual(["unchanged", "unchanged"]);
132
+ expect(again.notes.some((n) => n.includes("already has a refs rule for refs/heads/main"))).toBe(true);
133
+ });
134
+
135
+ test("an existing policy keeps its text and gets the rule added; one with a runner gets no hint", () => {
136
+ const r = new GateRepos("4913-init-edit");
137
+ const ci = runnerKey();
138
+ const before = `{\n "schema": 1,\n "runners": [{ "principal": "${RUNNER}", "class": "runner", "key": "${ci.pub}" }]\n}\n`;
139
+ r.write(".chant/trust.json", before);
140
+ r.commit("runner only");
141
+ const plan = refGateInitPlan(r.work, { branch: "trunk", checks: [{ check: "plan", command: "chant ci run plan" }], status: "acme/gate", prePush: false });
142
+ expect(plan.files).toHaveLength(1);
143
+ const trust = plan.files[0]!;
144
+ expect(trust.status).toBe("updated");
145
+ expect(trust.content.startsWith(`{\n "schema": 1,\n "runners": [{ "principal": "${RUNNER}"`)).toBe(true);
146
+ expect(JSON.parse(trust.content).refs).toEqual([{ ref: "refs/heads/trunk", checks: [{ check: "plan", command: "chant ci run plan" }], status: "acme/gate" }]);
147
+ expect(plan.notes.some((n) => n.includes("no runner key"))).toBe(false);
148
+ });
149
+
150
+ test("a rule that covers the branch, a policy that does not read, and a hook that is not chant's are left as they are", () => {
151
+ const r = new GateRepos("4913-init-leave");
152
+ r.write(".chant/trust.json", JSON.stringify({ schema: 1, refs: [{ ref: "refs/heads/*", checks: [{ check: "lint", command: "npm run lint" }] }] }));
153
+ r.commit("a wide rule");
154
+ const hooks = join(r.work, ".git", "hooks");
155
+ writeFileSync(join(hooks, "pre-push"), "#!/bin/sh\necho mine\n");
156
+ const plan = refGateInitPlan(r.work, { checks: CHECKS });
157
+ expect(plan.files.map((f) => [f.path.endsWith(".chant/trust.json"), f.status])).toEqual([[true, "unchanged"]]);
158
+ expect(plan.notes.some((n) => n.includes("already has a refs rule for refs/heads/main (refs/heads/*)"))).toBe(true);
159
+ expect(plan.notes.some((n) => n.includes("is not chant's ref gate hook"))).toBe(true);
160
+ expect(readFileSync(join(hooks, "pre-push"), "utf-8")).toContain("echo mine");
161
+
162
+ r.write(".chant/trust.json", "{ not json");
163
+ const bad = refGateInitPlan(r.work, { checks: CHECKS, prePush: false });
164
+ expect(bad.files).toEqual([]);
165
+ expect(bad.notes[0]).toContain("does not read as chant's trust policy");
166
+ });
167
+
168
+ test("#4978: with a product plan's targets, plan and policy are each target's, the checks the targets' note jobs sign", () => {
169
+ const r = new GateRepos("4978-init-targets");
170
+ r.commit("start");
171
+ const checks = [{ check: "lint", command: "npm run lint" }, { check: "plan", command: "/yodel plan" }, { check: "policy", action: "warn" as const, command: "/yodel plan" }];
172
+ const plan = refGateInitPlan(r.work, { checks, targets: ["staging", "prod"], prePush: false });
173
+ expect(JSON.parse(plan.files[0]!.content).refs[0].checks).toEqual([
174
+ { check: "lint", command: "npm run lint" },
175
+ { check: "plan:staging", command: "/yodel plan" },
176
+ { check: "plan:prod", command: "/yodel plan" },
177
+ { check: "policy:staging", action: "warn", command: "/yodel plan" },
178
+ { check: "policy:prod", action: "warn", command: "/yodel plan" },
179
+ ]);
180
+ expect(productPlanEvidenceChecks(["staging", "prod"])).toEqual(["plan:staging", "policy:staging", "plan:prod", "policy:prod"]);
181
+ expect(productPlanEvidenceChecks()).toEqual(["plan", "policy"]);
182
+ expect(targetEvidenceCheck("policy", "prod")).toBe("policy:prod");
183
+ expect(refGateInitChecks(checks, [])).toEqual(checks);
184
+ expect(() => refGateInitPlan(r.work, { checks, targets: ["no:colon"], prePush: false })).toThrow("is not a product plan target's name");
185
+ });
186
+
187
+ test("options no rule can hold, or a directory outside git, are refused", () => {
188
+ const r = new GateRepos("4913-init-refuse");
189
+ r.commit("start");
190
+ expect(() => refGateInitPlan(r.work, { checks: [] })).toThrow(RefGateInitError);
191
+ expect(() => refGateInitPlan(r.work, { checks: [{ check: "has space", command: "x" }] })).toThrow("is not a check name");
192
+ expect(() => refGateInitPlan(r.work, { branch: "release/*", checks: CHECKS })).toThrow(RefGateInitError);
193
+ expect(() => refGateInitPlan(r.home, { checks: CHECKS })).toThrow("is not in a git checkout");
194
+ expect(existsSync(join(r.work, ".chant/trust.json"))).toBe(false);
195
+ });
196
+ });
197
+
198
+ describe("the request for an override from a push the remote refused (#4913)", () => {
199
+ test("the pre-receive refusal prints the exact command that records it in the checkout, then the override and the push", () => {
200
+ const r = new GateRepos("4913-request");
201
+ const ci = runnerKey();
202
+ r.write(".chant/trust.json", trustJson(ci, CHECKS));
203
+ const base = r.commit("policy");
204
+ r.write("app/a.txt", "change\n");
205
+ const head = r.commit("a change");
206
+ const d = decideRefUpdate({ repo: r.work, update: { ref: "refs/heads/main", old: base, new: head }, base, lifecycle: null });
207
+ expect(d.decision).toBe("refuse");
208
+ expect(requestCommand(d)).toBe(`chant workspace ref-gate check --ref refs/heads/main --at ${head} --base ${base}`);
209
+
210
+ const remote = describeDecision(d, { site: "pre-receive" }).join("\n");
211
+ expect(remote).toContain("record the request for an override in your checkout (this remote can't)");
212
+ expect(remote).toContain(` chant workspace ref-gate check --ref refs/heads/main --at ${head} --base ${base}`);
213
+ expect(remote).toContain(`chant approve policy-override ref-gate-${head.slice(0, 12)}-plan --rule plan`);
214
+ expect(remote).toContain(`git push origin chant/lifecycle ${head}:refs/heads/main`);
215
+ expect(remote).not.toContain("lint --rule");
216
+
217
+ const local = describeDecision(d).join("\n");
218
+ expect(local).toContain(`the pre-push hook records it, or chant workspace ref-gate check --ref refs/heads/main --at ${head} --base ${base}`);
219
+ });
220
+ });
@@ -60,6 +60,23 @@ describe("the ref gate's hooks", () => {
60
60
  expect(r.run(r.origin, ["rev-parse", "main"]).trim()).toBe(head);
61
61
  }, 60_000);
62
62
 
63
+ test("a push only the remote refused prints the command that records the request for an override, and it does from the checkout (#4913)", () => {
64
+ const { r, base, head } = setup("e2e-request");
65
+ const installed = chant(r, r.work, ["workspace", "ref-gate", "install", "--hook", "pre-receive", "--git-dir", r.origin, "--chant", CHANT]);
66
+ expect(installed.status, installed.stderr).toBe(0);
67
+ const refused = push(r, `${head}:refs/heads/main`);
68
+ expect(refused.status).not.toBe(0);
69
+ const printed = refused.stderr.split("\n").map((l) => l.replace(/^remote:\s*/, "").trim()).find((l) => l.startsWith("chant workspace ref-gate check "));
70
+ expect(printed).toBe(`chant workspace ref-gate check --ref refs/heads/main --at ${head} --base ${base}`);
71
+
72
+ const recorded = chant(r, r.work, printed!.split(" ").slice(1));
73
+ expect(recorded.status).toBe(1);
74
+ expect(recorded.stderr).toContain("is recorded on chant/lifecycle");
75
+ const ledger = r.git(["show", "chant/lifecycle:_gates/policy-override.jsonl"]);
76
+ expect(ledger).toContain(`"gate":"ref-gate-${head.slice(0, 12)}-plan"`);
77
+ expect(ledger).toContain(`"gate":"ref-gate-${head.slice(0, 12)}-policy"`);
78
+ }, 60_000);
79
+
63
80
  test("chant's pre-push hook refuses the same push before the network", () => {
64
81
  const { r, ci, base, head } = setup("e2e-push");
65
82
  const installed = chant(r, r.work, ["workspace", "ref-gate", "install", "--hook", "pre-push", "--chant", CHANT]);
@@ -232,6 +232,16 @@ describe("the developer's side and the forge", () => {
232
232
  ]);
233
233
  });
234
234
 
235
+ test("a policy at base that does not read fails the status closed (#4964)", async () => {
236
+ const { r, base } = setup("status-unreadable");
237
+ r.write(".chant/trust.json", "{ not json");
238
+ const broken = r.commit("broken policy");
239
+ const posted: Array<{ sha: string; context: string; state: string; description: string }> = [];
240
+ const forge = { setStatus: async (sha: string, s: { context: string; state: string; description: string }) => void posted.push({ sha, ...s }) };
241
+ await postRefGateStatus(forge, decideRefUpdate({ repo: r.work, update: { ref: "refs/heads/main", old: base, new: broken }, base: broken, now: NOW }));
242
+ expect(posted).toEqual([{ sha: broken, context: "chant/ref-gate", state: "failure", description: "refused: trust-policy-unreadable" }]);
243
+ });
244
+
235
245
  test("the hooks run chant with git's arguments and input", () => {
236
246
  expect(refGateHook("pre-receive")).toBe('#!/bin/sh\n# chant ref gate (#4867)\nexec chant workspace ref-gate pre-receive "$@"\n');
237
247
  expect(refGateHook("pre-push", "npx chant")).toContain("exec npx chant workspace ref-gate pre-push");
@@ -37,7 +37,7 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
37
37
  import { dirname, isAbsolute, join } from "node:path";
38
38
  import type { ReasonCode } from "../reason-codes";
39
39
  import { verifyEvidence, type EvidenceErrorCode } from "./evidence";
40
- import { policyAtBase } from "./provenance";
40
+ import { policyAtBase, resolveBase } from "./provenance";
41
41
  import { runnersAt, type RefRule, type TrustPolicy } from "./policy";
42
42
  import {
43
43
  OVERRIDE_APPLIED,
@@ -172,6 +172,63 @@ export function rulesFor(policy: Pick<TrustPolicy, "refs">, ref: string): { matc
172
172
  };
173
173
  }
174
174
 
175
+ /** The ref gate's rules for one ref, read at base, as a product reads them (#4913). */
176
+ export interface RefGateRules {
177
+ ref: string;
178
+ /** The commit the policy was read at, or null when there is none. */
179
+ base: string | null;
180
+ /** A rule of the policy at base matches the ref. */
181
+ matched: boolean;
182
+ /** The commit status the ref gate's status job sets for the ref, which the forge should require; null when no rule matches. */
183
+ status: string | null;
184
+ /** The checks an update of the ref needs current evidence for, each once, as {@link rulesFor} merges them. */
185
+ checks: RefRule["checks"];
186
+ overrides?: "ledger" | "sealed";
187
+ /**
188
+ * Why the policy at base cannot be read. The gate then refuses every
189
+ * update of the ref and sets no status, so a product should refuse too.
190
+ */
191
+ problems: string[];
192
+ }
193
+
194
+ /**
195
+ * The ref gate's rules for `ref` from the policy at `base` (#4913), the same
196
+ * read {@link decideRefUpdate} makes, for a product that acts on them
197
+ * without deciding an update: an apply that waits for the status the gate
198
+ * sets (`@intentius/chant/ref-gate-rules`), or a forge check that requires
199
+ * it. `base` defaults as `check` and `status` default it: `origin/HEAD`,
200
+ * then `main`, then `master`. A base that names no commit is a problem; no
201
+ * base at all is no policy, so nothing is required.
202
+ */
203
+ export function refGateRulesAt(repo: string, opts: { ref: string; base?: string }): RefGateRules {
204
+ const resolved = resolveBase(repo, opts.base);
205
+ const none = { ref: opts.ref, base: resolved.commit, matched: false, status: null, checks: [] };
206
+ if (!resolved.commit) return { ...none, problems: opts.base !== undefined && resolved.problem ? [resolved.problem] : [] };
207
+ const policy = policyAtBase(repo, resolved);
208
+ if (policy.problems.length > 0) return { ...none, problems: [...policy.problems] };
209
+ const rules = rulesFor(policy, opts.ref);
210
+ if (!rules.matched) return { ...none, problems: [] };
211
+ return { ref: opts.ref, base: resolved.commit, matched: true, status: rules.status, checks: rules.checks, ...(rules.overrides ? { overrides: rules.overrides } : {}), problems: [] };
212
+ }
213
+
214
+ /**
215
+ * The status a forge's default branch should require for the ref gate
216
+ * (#4913), for a forge check whose pipeline renders the `ref-gate` job: the
217
+ * policy's status for `refs/heads/<defaultBranch>`, read at
218
+ * `origin/<defaultBranch>` when the checkout has it, else at `HEAD`. With
219
+ * no rule for the branch the job sets no status, so none is required and
220
+ * `note` says so; a policy that can't be read is a `problem`.
221
+ */
222
+ export function refGateStatusFor(repo: string, defaultBranch: string): { status?: string; note?: string; problem?: string } {
223
+ const remote = `refs/remotes/origin/${defaultBranch}`;
224
+ const rules = refGateRulesAt(repo, { ref: `refs/heads/${defaultBranch}`, base: commitOf(repo, remote) ? remote : "HEAD" });
225
+ if (rules.problems.length > 0) return { problem: `the trust policy can't be read, so the ref gate sets no status to require: ${rules.problems.join("; ")}` };
226
+ if (!rules.matched || !rules.status) {
227
+ return { note: `no refs rule in .chant/trust.json${rules.base ? ` at ${rules.base.slice(0, 8)}` : ""} matches refs/heads/${defaultBranch}, so the ref-gate job sets no status there and none is required` };
228
+ }
229
+ return { status: rules.status };
230
+ }
231
+
175
232
  // ── evidence notes ───────────────────────────────────────────────────────
176
233
 
177
234
  /** The envelopes in a note's text: one per line, or the whole note as one envelope or an array of them. */
@@ -510,8 +567,24 @@ export function runPrePush(repo: string, stdin: string, opts: { ledger?: string;
510
567
 
511
568
  const short = (s: string | null): string => (s ? s.slice(0, 8) : "(none)");
512
569
 
513
- /** What the gate says about one decision: each missing check and its command, and how to override a blocked one. */
514
- export function describeDecision(d: RefDecision): string[] {
570
+ /**
571
+ * The command that records the request for an override of `d`'s blocked
572
+ * checks from a checkout (#4913): `check` for the same ref, commit and base
573
+ * the remote decided, so it reaches the same decision and records the
574
+ * request on `chant/lifecycle`, which a pre-receive hook can't move.
575
+ */
576
+ export function requestCommand(d: Pick<RefDecision, "ref" | "new" | "base">): string {
577
+ return `chant workspace ref-gate check --ref ${d.ref} --at ${d.new ?? "HEAD"}${d.base ? ` --base ${d.base}` : ""}`;
578
+ }
579
+
580
+ /**
581
+ * What the gate says about one decision: each missing check and its command,
582
+ * and how to override a blocked one. At `pre-receive` (#4913) the request
583
+ * can't be recorded where the decision is made, so the refusal prints the
584
+ * exact command that records it from the checkout, then the override and
585
+ * the push that spends it.
586
+ */
587
+ export function describeDecision(d: RefDecision, opts: { site?: RefGateSite } = {}): string[] {
515
588
  const out: string[] = [];
516
589
  const verb = d.decision === "admit" ? "admitted" : "refused";
517
590
  out.push(`chant ref gate: ${verb} ${d.ref} ${short(d.old)}..${short(d.new)}`);
@@ -531,9 +604,17 @@ export function describeDecision(d: RefDecision): string[] {
531
604
  const blocked = d.checks.filter((c) => c.action === "block" && (c.status === "missing" || c.status === "stale"));
532
605
  if (blocked.length > 0) {
533
606
  out.push(` Attach each check's evidence to ${short(d.new)} (chant workspace ref-gate attach --envelope <file> --at ${short(d.new)}) and push ${EVIDENCE_NOTES_REF} with the ref.`);
534
- out.push(` To let ${short(d.new)} through without a check, a person listed in ${OVERRIDERS_PATH} at base can override it once the request is recorded`);
535
- out.push(` (the pre-push hook records it, or chant workspace ref-gate check --ref ${d.ref} --at ${short(d.new)}):`);
536
- for (const c of blocked) out.push(` ${overrideCommand(c.subject, [c.check])}`);
607
+ if (opts.site === "pre-receive") {
608
+ out.push(` To let ${short(d.new)} through without a check, record the request for an override in your checkout (this remote can't):`);
609
+ out.push(` ${requestCommand(d)}`);
610
+ out.push(` then a person listed in ${OVERRIDERS_PATH} at base overrides each check:`);
611
+ for (const c of blocked) out.push(` ${overrideCommand(c.subject, [c.check])}`);
612
+ out.push(` and the push goes again with chant/lifecycle: git push origin chant/lifecycle ${d.new ?? "HEAD"}:${d.ref}`);
613
+ } else {
614
+ out.push(` To let ${short(d.new)} through without a check, a person listed in ${OVERRIDERS_PATH} at base can override it once the request is recorded`);
615
+ out.push(` (the pre-push hook records it, or ${requestCommand(d)}):`);
616
+ for (const c of blocked) out.push(` ${overrideCommand(c.subject, [c.check])}`);
617
+ }
537
618
  }
538
619
  return out;
539
620
  }
@@ -47,6 +47,7 @@ import { executePlan, planMembers } from "./member-commands";
47
47
  import { locateWorkspace } from "./which-chant";
48
48
  import { appendWorkspaceRun, type WorkspaceRunRecord, type WorkspaceRunStep } from "./workspace-ledger";
49
49
  import { appendWorkspaceGatePending, type WorkspaceGateCover, type WorkspaceGatePending } from "./workspace-gates";
50
+ import { actorFromEnv } from "../actor";
50
51
 
51
52
  /** `chant run`'s exit code for a run that stopped at an unapproved gate (`GATED_EXIT_CODE`). */
52
53
  const GATED_EXIT = CHANT_EXIT.waiting;
@@ -444,7 +445,7 @@ async function runWorkspaceRunApprove(ctx: CommandContext, words: string[]): Pro
444
445
  return 1;
445
446
  }
446
447
  const { approveWorkspaceGate } = await import("./workspace-gates");
447
- const approvedBy = ctx.args.approver ?? ctx.args.actor ?? process.env.GITHUB_ACTOR ?? process.env.GITLAB_USER_LOGIN ?? process.env.USER ?? "unknown";
448
+ const approvedBy = ctx.args.approver ?? ctx.args.actor ?? actorFromEnv();
448
449
  try {
449
450
  const record = await approveWorkspaceGate(resolve("."), {
450
451
  gate,