@intentius/chant 0.124.86 → 0.124.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/dist/action-pins.d.ts +1 -0
  2. package/dist/action-pins.d.ts.map +1 -1
  3. package/dist/action-pins.js +2 -0
  4. package/dist/actor.d.ts +12 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +18 -0
  7. package/dist/bundle-check.d.ts +20 -5
  8. package/dist/bundle-check.d.ts.map +1 -1
  9. package/dist/bundle-check.js +20 -5
  10. package/dist/chant-install.d.ts +98 -0
  11. package/dist/chant-install.d.ts.map +1 -1
  12. package/dist/chant-install.js +204 -2
  13. package/dist/ci-commit.d.ts.map +1 -1
  14. package/dist/ci-commit.js +1 -2
  15. package/dist/ci-control.d.ts +1 -1
  16. package/dist/ci-control.d.ts.map +1 -1
  17. package/dist/ci-control.js +1 -1
  18. package/dist/ci-evidence-claims.d.ts +59 -0
  19. package/dist/ci-evidence-claims.d.ts.map +1 -0
  20. package/dist/ci-evidence-claims.js +87 -0
  21. package/dist/ci-evidence-from-job.d.ts +103 -0
  22. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  23. package/dist/ci-evidence-from-job.js +162 -0
  24. package/dist/ci-evidence-jobs.d.ts +69 -10
  25. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  26. package/dist/ci-evidence-jobs.js +72 -8
  27. package/dist/ci-handover.d.ts +12 -0
  28. package/dist/ci-handover.d.ts.map +1 -1
  29. package/dist/ci-handover.js +15 -3
  30. package/dist/ci-identity.d.ts +32 -6
  31. package/dist/ci-identity.d.ts.map +1 -1
  32. package/dist/ci-identity.js +40 -8
  33. package/dist/ci-image.d.ts +47 -9
  34. package/dist/ci-image.d.ts.map +1 -1
  35. package/dist/ci-image.js +45 -18
  36. package/dist/ci-jobs.d.ts +1 -1
  37. package/dist/ci-jobs.d.ts.map +1 -1
  38. package/dist/ci-jobs.js +7 -2
  39. package/dist/ci-login.d.ts +75 -13
  40. package/dist/ci-login.d.ts.map +1 -1
  41. package/dist/ci-login.js +89 -37
  42. package/dist/ci-product-words.d.ts +20 -1
  43. package/dist/ci-product-words.d.ts.map +1 -1
  44. package/dist/ci-product-words.js +27 -1
  45. package/dist/ci-product.d.ts +20 -1
  46. package/dist/ci-product.d.ts.map +1 -1
  47. package/dist/ci-product.js +21 -2
  48. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  49. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  50. package/dist/cli/handlers/approve-confirm.js +46 -0
  51. package/dist/cli/handlers/build.d.ts +1 -1
  52. package/dist/cli/handlers/build.d.ts.map +1 -1
  53. package/dist/cli/handlers/build.js +22 -1
  54. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  55. package/dist/cli/handlers/ci-check.js +38 -14
  56. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  57. package/dist/cli/handlers/ci-evidence.js +238 -26
  58. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  59. package/dist/cli/handlers/ci-forge-check.js +34 -17
  60. package/dist/cli/handlers/generated-check.d.ts +3 -0
  61. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  62. package/dist/cli/handlers/generated-check.js +41 -0
  63. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  64. package/dist/cli/handlers/lifecycle.js +3 -0
  65. package/dist/cli/handlers/local-chant.d.ts +13 -0
  66. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  67. package/dist/cli/handlers/local-chant.js +42 -1
  68. package/dist/cli/handlers/pr.d.ts.map +1 -1
  69. package/dist/cli/handlers/pr.js +42 -5
  70. package/dist/cli/handlers/run-wave.js +8 -0
  71. package/dist/cli/main.d.ts.map +1 -1
  72. package/dist/cli/main.js +38 -4
  73. package/dist/cli/parse-args.d.ts.map +1 -1
  74. package/dist/cli/parse-args.js +66 -0
  75. package/dist/cli/registry.d.ts +24 -0
  76. package/dist/cli/registry.d.ts.map +1 -1
  77. package/dist/components/check-hooks.d.ts +10 -0
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-hooks.js +21 -3
  80. package/dist/components/check-steps.js +1 -1
  81. package/dist/components/pr-checks.d.ts +105 -0
  82. package/dist/components/pr-checks.d.ts.map +1 -0
  83. package/dist/components/pr-checks.js +119 -0
  84. package/dist/components/pr-pipeline.d.ts +34 -0
  85. package/dist/components/pr-pipeline.d.ts.map +1 -1
  86. package/dist/components/pr-pipeline.js +14 -1
  87. package/dist/components/product-pipeline.d.ts +16 -1
  88. package/dist/components/product-pipeline.d.ts.map +1 -1
  89. package/dist/components/product-pipeline.js +17 -2
  90. package/dist/components/product-plan.d.ts +262 -3
  91. package/dist/components/product-plan.d.ts.map +1 -1
  92. package/dist/components/product-plan.js +243 -11
  93. package/dist/config.d.ts +10 -6
  94. package/dist/config.d.ts.map +1 -1
  95. package/dist/config.js +11 -6
  96. package/dist/control/consumers.d.ts +6 -0
  97. package/dist/control/consumers.d.ts.map +1 -1
  98. package/dist/control/consumers.js +6 -0
  99. package/dist/dead-guards.d.ts.map +1 -1
  100. package/dist/dead-guards.js +9 -6
  101. package/dist/discovery/files.d.ts +1 -1
  102. package/dist/discovery/files.js +1 -1
  103. package/dist/drift-issue.d.ts +20 -3
  104. package/dist/drift-issue.d.ts.map +1 -1
  105. package/dist/drift-issue.js +16 -0
  106. package/dist/drift-record.d.ts +45 -5
  107. package/dist/drift-record.d.ts.map +1 -1
  108. package/dist/drift-record.js +27 -6
  109. package/dist/floor-table.d.ts +6 -6
  110. package/dist/floor-table.d.ts.map +1 -1
  111. package/dist/floor-table.data.d.ts.map +1 -1
  112. package/dist/floor-table.data.js +58 -20
  113. package/dist/floor-table.js +10 -7
  114. package/dist/forge-check/contract.d.ts +8 -0
  115. package/dist/forge-check/contract.d.ts.map +1 -1
  116. package/dist/forge-check/contract.js +4 -1
  117. package/dist/forge-check/index.d.ts +2 -0
  118. package/dist/forge-check/index.d.ts.map +1 -1
  119. package/dist/forge-check/index.js +2 -0
  120. package/dist/forge-flags.d.ts +10 -0
  121. package/dist/forge-flags.d.ts.map +1 -1
  122. package/dist/forge-flags.js +31 -0
  123. package/dist/forge-remote.d.ts +47 -0
  124. package/dist/forge-remote.d.ts.map +1 -0
  125. package/dist/forge-remote.js +69 -0
  126. package/dist/generated-check.d.ts +74 -0
  127. package/dist/generated-check.d.ts.map +1 -0
  128. package/dist/generated-check.js +216 -0
  129. package/dist/lexicon.d.ts +16 -0
  130. package/dist/lexicon.d.ts.map +1 -1
  131. package/dist/lifecycle/publish-npm.d.ts +15 -0
  132. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  133. package/dist/lifecycle/publish-npm.js +49 -3
  134. package/dist/lifecycle/release-images.d.ts +22 -1
  135. package/dist/lifecycle/release-images.d.ts.map +1 -1
  136. package/dist/lifecycle/release-images.js +27 -3
  137. package/dist/lifecycle/release-ledger.d.ts +4 -3
  138. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  139. package/dist/lifecycle/release-ledger.js +3 -2
  140. package/dist/local-chant.d.ts +57 -3
  141. package/dist/local-chant.d.ts.map +1 -1
  142. package/dist/local-chant.js +122 -13
  143. package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
  144. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  145. package/dist/op/op-waves-evidence-jobs.js +112 -0
  146. package/dist/op/op-waves-evidence.d.ts +17 -4
  147. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  148. package/dist/op/op-waves-evidence.js +32 -10
  149. package/dist/op/op-waves-run.d.ts +12 -1
  150. package/dist/op/op-waves-run.d.ts.map +1 -1
  151. package/dist/op/op-waves-run.js +54 -3
  152. package/dist/op/op-waves.d.ts +8 -0
  153. package/dist/op/op-waves.d.ts.map +1 -1
  154. package/dist/op/op-waves.js +10 -0
  155. package/dist/op/schedule-overdue.d.ts +39 -2
  156. package/dist/op/schedule-overdue.d.ts.map +1 -1
  157. package/dist/op/schedule-overdue.js +89 -7
  158. package/dist/pr-forge-reads.d.ts +21 -1
  159. package/dist/pr-forge-reads.d.ts.map +1 -1
  160. package/dist/pr-forge-reads.js +19 -1
  161. package/dist/pr-forge.d.ts +7 -1
  162. package/dist/pr-forge.d.ts.map +1 -1
  163. package/dist/pr-forge.js +7 -2
  164. package/dist/pr-plan-note.d.ts +24 -0
  165. package/dist/pr-plan-note.d.ts.map +1 -1
  166. package/dist/pr-plan-note.js +11 -1
  167. package/dist/pr-plan-record.d.ts +47 -0
  168. package/dist/pr-plan-record.d.ts.map +1 -0
  169. package/dist/pr-plan-record.js +89 -0
  170. package/dist/pr-post.d.ts +40 -0
  171. package/dist/pr-post.d.ts.map +1 -1
  172. package/dist/pr-post.js +79 -6
  173. package/dist/pr-requires.d.ts +8 -0
  174. package/dist/pr-requires.d.ts.map +1 -1
  175. package/dist/pr-requires.js +3 -1
  176. package/dist/ref-gate-init.d.ts +76 -0
  177. package/dist/ref-gate-init.d.ts.map +1 -0
  178. package/dist/ref-gate-init.js +144 -0
  179. package/dist/ref-gate-rules.d.ts +19 -0
  180. package/dist/ref-gate-rules.d.ts.map +1 -0
  181. package/dist/ref-gate-rules.js +17 -0
  182. package/dist/release-floors.d.ts +51 -1
  183. package/dist/release-floors.d.ts.map +1 -1
  184. package/dist/release-floors.js +66 -16
  185. package/dist/state-migration.d.ts +23 -0
  186. package/dist/state-migration.d.ts.map +1 -1
  187. package/dist/state-migration.js +39 -3
  188. package/dist/state-unlock.d.ts +32 -1
  189. package/dist/state-unlock.d.ts.map +1 -1
  190. package/dist/state-unlock.js +31 -0
  191. package/dist/wave-runtime.mjs +310 -303
  192. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  193. package/dist/workspace/ci-green-cli.js +13 -7
  194. package/dist/workspace/ci-green.d.ts.map +1 -1
  195. package/dist/workspace/ci-green.js +4 -3
  196. package/dist/workspace/drift-cli.d.ts +1 -1
  197. package/dist/workspace/drift-cli.d.ts.map +1 -1
  198. package/dist/workspace/drift-cli.js +5 -12
  199. package/dist/workspace/forge-work.d.ts +3 -2
  200. package/dist/workspace/forge-work.d.ts.map +1 -1
  201. package/dist/workspace/forge-work.js +7 -17
  202. package/dist/workspace/lexicon-outputs.js +2 -2
  203. package/dist/workspace/release-workflow.d.ts +26 -3
  204. package/dist/workspace/release-workflow.d.ts.map +1 -1
  205. package/dist/workspace/release-workflow.js +48 -6
  206. package/dist/workspace/trust/check-evidence-report.d.ts +25 -0
  207. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  208. package/dist/workspace/trust/check-evidence-report.js +20 -0
  209. package/dist/workspace/trust/check-evidence.d.ts +59 -13
  210. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  211. package/dist/workspace/trust/check-evidence.js +101 -24
  212. package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
  213. package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
  214. package/dist/workspace/trust/dsse.d.ts +40 -2
  215. package/dist/workspace/trust/dsse.d.ts.map +1 -1
  216. package/dist/workspace/trust/dsse.js +34 -2
  217. package/dist/workspace/trust/evidence.d.ts +7 -2
  218. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  219. package/dist/workspace/trust/evidence.js +5 -0
  220. package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
  221. package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
  222. package/dist/workspace/trust/keyless-fixture.js +161 -0
  223. package/dist/workspace/trust/keyless.d.ts +202 -0
  224. package/dist/workspace/trust/keyless.d.ts.map +1 -0
  225. package/dist/workspace/trust/keyless.js +488 -0
  226. package/dist/workspace/trust/local-evidence.d.ts +3 -0
  227. package/dist/workspace/trust/local-evidence.d.ts.map +1 -1
  228. package/dist/workspace/trust/op-run-statement.d.ts +2 -2
  229. package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
  230. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  231. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  232. package/dist/workspace/trust/open-evidence.js +92 -0
  233. package/dist/workspace/trust/policy.d.ts +56 -1
  234. package/dist/workspace/trust/policy.d.ts.map +1 -1
  235. package/dist/workspace/trust/policy.js +103 -2
  236. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  237. package/dist/workspace/trust/ref-gate-cli.js +65 -3
  238. package/dist/workspace/trust/ref-gate.d.ts +62 -3
  239. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  240. package/dist/workspace/trust/ref-gate.js +75 -8
  241. package/dist/workspace/trust/run-statement.d.ts +3 -3
  242. package/dist/workspace/trust/run-statement.d.ts.map +1 -1
  243. package/dist/workspace/trust/runner-identity.d.ts +56 -0
  244. package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
  245. package/dist/workspace/trust/runner-identity.js +65 -0
  246. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  247. package/dist/workspace/trust/trust-files.js +8 -1
  248. package/package.json +1 -1
  249. package/src/action-pins.ts +2 -0
  250. package/src/actor.test.ts +12 -0
  251. package/src/actor.ts +19 -0
  252. package/src/bundle-check.test.ts +22 -0
  253. package/src/bundle-check.ts +33 -5
  254. package/src/chant-install.test.ts +109 -1
  255. package/src/chant-install.ts +243 -2
  256. package/src/ci-commit.test.ts +51 -5
  257. package/src/ci-commit.ts +1 -2
  258. package/src/ci-control.ts +1 -0
  259. package/src/ci-evidence-claims.ts +102 -0
  260. package/src/ci-evidence-from-job.test.ts +147 -0
  261. package/src/ci-evidence-from-job.ts +195 -0
  262. package/src/ci-evidence-jobs.ts +85 -10
  263. package/src/ci-handover.ts +16 -3
  264. package/src/ci-identity.test.ts +3 -3
  265. package/src/ci-identity.ts +51 -11
  266. package/src/ci-image.test.ts +60 -10
  267. package/src/ci-image.ts +78 -19
  268. package/src/ci-jobs.ts +7 -2
  269. package/src/ci-login.test.ts +131 -3
  270. package/src/ci-login.token-drop.test.ts +204 -0
  271. package/src/ci-login.ts +137 -39
  272. package/src/ci-product-words.ts +30 -0
  273. package/src/ci-product.ts +26 -1
  274. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  275. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  276. package/src/cli/handlers/approve-confirm.ts +44 -0
  277. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  278. package/src/cli/handlers/build.ts +20 -2
  279. package/src/cli/handlers/ci-check.ts +35 -13
  280. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  281. package/src/cli/handlers/ci-evidence.ts +223 -24
  282. package/src/cli/handlers/ci-forge-check.ts +22 -9
  283. package/src/cli/handlers/generated-check.ts +39 -0
  284. package/src/cli/handlers/lifecycle.test.ts +20 -0
  285. package/src/cli/handlers/lifecycle.ts +4 -0
  286. package/src/cli/handlers/local-chant.ts +39 -1
  287. package/src/cli/handlers/pr.ts +43 -5
  288. package/src/cli/handlers/run-wave.ts +7 -0
  289. package/src/cli/main.ts +38 -4
  290. package/src/cli/parse-args.ts +46 -0
  291. package/src/cli/registry.ts +24 -0
  292. package/src/components/check-hooks.ts +25 -3
  293. package/src/components/check-report-summary.test.ts +78 -0
  294. package/src/components/check-steps.ts +1 -1
  295. package/src/components/pr-checks.ts +159 -0
  296. package/src/components/pr-pipeline.ts +41 -1
  297. package/src/components/product-pipeline.ts +25 -3
  298. package/src/components/product-plan.test.ts +102 -1
  299. package/src/components/product-plan.ts +419 -14
  300. package/src/config.ts +13 -8
  301. package/src/control/consumers.ts +7 -0
  302. package/src/dead-guards.test.ts +27 -5
  303. package/src/dead-guards.ts +9 -6
  304. package/src/discovery/files.ts +1 -1
  305. package/src/drift-issue.test.ts +29 -1
  306. package/src/drift-issue.ts +28 -3
  307. package/src/drift-record.test.ts +25 -0
  308. package/src/drift-record.ts +55 -6
  309. package/src/floor-table.data.ts +58 -20
  310. package/src/floor-table.ts +12 -9
  311. package/src/forge-check/contract.ts +11 -1
  312. package/src/forge-check/forge-check.test.ts +8 -0
  313. package/src/forge-check/index.ts +2 -0
  314. package/src/forge-flags.test.ts +25 -1
  315. package/src/forge-flags.ts +34 -0
  316. package/src/forge-remote.test.ts +37 -0
  317. package/src/forge-remote.ts +79 -0
  318. package/src/generated-check.e2e.test.ts +98 -0
  319. package/src/generated-check.test.ts +104 -0
  320. package/src/generated-check.ts +269 -0
  321. package/src/lexicon.ts +17 -0
  322. package/src/lifecycle/publish-npm.ts +56 -3
  323. package/src/lifecycle/release-catalog.test.ts +2 -2
  324. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  325. package/src/lifecycle/release-images.test.ts +44 -0
  326. package/src/lifecycle/release-images.ts +39 -3
  327. package/src/lifecycle/release-ledger.ts +4 -3
  328. package/src/local-chant.e2e.test.ts +81 -6
  329. package/src/local-chant.test.ts +22 -3
  330. package/src/local-chant.ts +130 -13
  331. package/src/op/op-waves-evidence-jobs.ts +134 -0
  332. package/src/op/op-waves-evidence.test.ts +37 -4
  333. package/src/op/op-waves-evidence.ts +32 -11
  334. package/src/op/op-waves-run.ts +57 -2
  335. package/src/op/op-waves.ts +11 -0
  336. package/src/op/schedule-overdue.test.ts +83 -1
  337. package/src/op/schedule-overdue.ts +107 -9
  338. package/src/pr-forge-reads-compare.test.ts +2 -1
  339. package/src/pr-forge-reads.ts +37 -1
  340. package/src/pr-forge.ts +14 -3
  341. package/src/pr-plan-note.ts +32 -3
  342. package/src/pr-plan-record.test.ts +75 -0
  343. package/src/pr-plan-record.ts +101 -0
  344. package/src/pr-post-plan-note.test.ts +60 -0
  345. package/src/pr-post.test.ts +30 -0
  346. package/src/pr-post.ts +110 -6
  347. package/src/pr-requires.test.ts +20 -0
  348. package/src/pr-requires.ts +10 -1
  349. package/src/ref-gate-init.ts +189 -0
  350. package/src/ref-gate-rules.ts +26 -0
  351. package/src/release-floors.ts +88 -16
  352. package/src/state-migration-record.test.ts +90 -0
  353. package/src/state-migration.test.ts +1 -1
  354. package/src/state-migration.ts +52 -3
  355. package/src/state-unlock.test.ts +33 -1
  356. package/src/state-unlock.ts +49 -1
  357. package/src/workspace/ci-green-cli.ts +12 -6
  358. package/src/workspace/ci-green.ts +4 -3
  359. package/src/workspace/drift-cli.ts +6 -18
  360. package/src/workspace/forge-work.ts +7 -14
  361. package/src/workspace/lexicon-outputs.ts +2 -2
  362. package/src/workspace/release-workflow.test.ts +70 -0
  363. package/src/workspace/release-workflow.ts +56 -8
  364. package/src/workspace/trust/check-evidence-report.ts +33 -0
  365. package/src/workspace/trust/check-evidence.test.ts +3 -3
  366. package/src/workspace/trust/check-evidence.ts +110 -28
  367. package/src/workspace/trust/ci-tag-statement.ts +2 -2
  368. package/src/workspace/trust/dsse.ts +48 -4
  369. package/src/workspace/trust/evidence.ts +7 -2
  370. package/src/workspace/trust/keyless-fixture.ts +214 -0
  371. package/src/workspace/trust/keyless.test.ts +220 -0
  372. package/src/workspace/trust/keyless.ts +557 -0
  373. package/src/workspace/trust/local-evidence.ts +3 -1
  374. package/src/workspace/trust/op-run-statement.ts +2 -2
  375. package/src/workspace/trust/open-evidence.ts +129 -0
  376. package/src/workspace/trust/policy.ts +129 -2
  377. package/src/workspace/trust/ref-gate-cli.ts +59 -3
  378. package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
  379. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  380. package/src/workspace/trust/ref-gate.ts +90 -8
  381. package/src/workspace/trust/run-statement.ts +3 -3
  382. package/src/workspace/trust/runner-identity.ts +92 -0
  383. package/src/workspace/trust/trust-files.test.ts +6 -0
  384. package/src/workspace/trust/trust-files.ts +14 -1
@@ -10,15 +10,20 @@
10
10
  * failed. See `../../components/check-hooks.ts` and
11
11
  * `../../components/check-steps.ts`.
12
12
  *
13
- * With a runner key in `CHANT_RUNNER_KEY` (#4870), each hook that passed is
13
+ * With a runner key in `CHANT_RUNNER_KEY` (#4870), or `CHANT_RUNNER_IDENTITY=oidc`
14
+ * to sign keyless from the job's OIDC identity (#4869), each hook that passed is
14
15
  * signed as a named check over `HEAD` and attached under `refs/notes/chant/evidence`, which
15
- * is pushed unless `--no-push`; the key never reaches a hook.
16
+ * is pushed unless `--no-push`; neither the key nor the token request reaches a hook.
16
17
  *
17
18
  * #4868: with a local key in `CHANT_LOCAL_EVIDENCE_KEY` (a developer's or an
18
19
  * agent session's, listed under `local.keys` at base) each hook that passed
19
20
  * is signed as local evidence instead, under `refs/notes/chant/local-evidence`.
20
21
  * Without one, a hook whose check `local.checks` at base names is skipped
21
22
  * when current local evidence for the tree stands in for it; the rest run.
23
+ *
24
+ * #4914: `--summary <file>` appends the report's markdown section
25
+ * (`checkReportSummary`) to the file, as a product's check report keeps it,
26
+ * and a job with `GITHUB_STEP_SUMMARY` set gets it in its summary too.
22
27
  */
23
28
  import { resolve } from "node:path";
24
29
  import type { CheckStageEvidence, CheckStepsAdapter } from "../../components/check-steps";
@@ -44,27 +49,30 @@ async function lexiconCheckSteps(ctx: CommandContext, cwd: string): Promise<Chec
44
49
  return plugins.map((p) => p.checkSteps?.()).filter((a): a is CheckStepsAdapter => a !== undefined);
45
50
  }
46
51
 
47
- const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--no-push] [--json]";
52
+ const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--summary <file>] [--no-push] [--json]";
48
53
 
49
54
  /**
50
- * The check stage's signer (#4870), when the job holds a runner key in
51
- * `CHANT_RUNNER_KEY`: the runner `.chant/trust.json` at `base` lists for it.
52
- * Throws when the key is there and the policy at base does not list it, so
53
- * a job asked to sign never passes while signing nothing.
55
+ * The check stage's signer (#4870), when the job has a runner identity: a
56
+ * runner key in `CHANT_RUNNER_KEY`, or its OIDC identity with
57
+ * `CHANT_RUNNER_IDENTITY=oidc` (#4869), as `.chant/trust.json` at `base`
58
+ * lists it. Throws when the job has one and the policy at base does not
59
+ * list it, so a job asked to sign never passes while signing nothing.
54
60
  */
55
61
  async function checkEvidenceSigner(base: string, noPush: boolean): Promise<CheckStageEvidence | undefined> {
56
- const { CHECK_EVIDENCE_KEY_ENV, LOCAL_EVIDENCE_KEY_ENV } = await import("../../workspace/trust/check-evidence-report");
57
- const pem = process.env[CHECK_EVIDENCE_KEY_ENV];
62
+ const { CHECK_EVIDENCE_KEY_ENV, LOCAL_EVIDENCE_KEY_ENV, RUNNER_IDENTITY_ENV } = await import("../../workspace/trust/check-evidence-report");
63
+ const runner = process.env[CHECK_EVIDENCE_KEY_ENV] || process.env[RUNNER_IDENTITY_ENV];
58
64
  const localPem = process.env[LOCAL_EVIDENCE_KEY_ENV];
59
- if (!pem && !localPem) return undefined;
60
- if (pem && localPem) throw new Error(`${CHECK_EVIDENCE_KEY_ENV} and ${LOCAL_EVIDENCE_KEY_ENV} are both set; a job signs as a runner or as a person or agent, never both`);
65
+ if (!runner && !localPem) return undefined;
66
+ if (runner && localPem) throw new Error(`${process.env[CHECK_EVIDENCE_KEY_ENV] ? CHECK_EVIDENCE_KEY_ENV : RUNNER_IDENTITY_ENV} and ${LOCAL_EVIDENCE_KEY_ENV} are both set; a job signs as a runner or as a person or agent, never both`);
61
67
  const { top, commit } = await baseCommit(base);
62
68
  if (localPem) {
63
69
  const { localKeyEvidenceSigner } = await import("../../workspace/trust/local-evidence");
64
70
  return { signer: localKeyEvidenceSigner(top, commit, localPem), ...(noPush ? { push: false } : {}) };
65
71
  }
66
- const { runnerKeyEvidenceSigner } = await import("../../workspace/trust/check-evidence");
67
- return { signer: runnerKeyEvidenceSigner(top, commit, pem!), ...(noPush ? { push: false } : {}) };
72
+ // #4869: the runner key, or the job's OIDC identity, read in one place.
73
+ const { runnerEvidenceSigner } = await import("../../workspace/trust/check-evidence");
74
+ const signer = await runnerEvidenceSigner(top, commit);
75
+ return signer ? { signer, ...(noPush ? { push: false } : {}) } : undefined;
68
76
  }
69
77
 
70
78
  async function baseCommit(base: string): Promise<{ top: string; commit: string }> {
@@ -102,6 +110,20 @@ export async function runCiCheck(ctx: CommandContext): Promise<number> {
102
110
  console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
103
111
  return CHANT_EXIT.failed;
104
112
  }
113
+ // #4914: the report's markdown section, in the product's own report and the job summary of a forge that keeps one.
114
+ for (const file of [...new Set([args.checkSummary, process.env.GITHUB_STEP_SUMMARY].filter((f): f is string => Boolean(f)))]) {
115
+ const { checkReportSummary } = await import("../../components/check-hooks");
116
+ const lines = checkReportSummary(report);
117
+ if (lines.length === 0) continue;
118
+ try {
119
+ const { appendFileSync, mkdirSync } = await import("node:fs");
120
+ const { dirname } = await import("node:path");
121
+ mkdirSync(dirname(resolve(file)), { recursive: true });
122
+ appendFileSync(file, `${lines.join("\n")}\n`);
123
+ } catch (err) {
124
+ console.error(`ci check: could not write the summary to ${file}: ${err instanceof Error ? err.message : String(err)}`);
125
+ }
126
+ }
105
127
  if (args.json) console.log(JSON.stringify(report, null, 2));
106
128
  else if (report.status === "none") console.error("ci check: no ci.hooks.check at base and no lexicon check step, so nothing ran");
107
129
  else {
@@ -0,0 +1,164 @@
1
+ /**
2
+ * #4914: `chant ci evidence sign --open`, the GitLab signing job of the
3
+ * target branch's plan notes pipeline. For each open merge request it reads
4
+ * the newest plan or check job's report from its artifact, signs it for the
5
+ * head, keeps `<out>/<iid>/evidence.json` naming the head, and does not
6
+ * sign a head again once its evidence is current. The forge is a fake; the
7
+ * repository, the runner key and the notes are real.
8
+ */
9
+
10
+ import { execFileSync } from "node:child_process";
11
+ import { generateKeyPairSync } from "node:crypto";
12
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { tmpdir } from "node:os";
14
+ import { join } from "node:path";
15
+ import { afterEach, describe, expect, test, vi } from "vitest";
16
+ import { loadRunnerKey } from "../../workspace/trust/dsse";
17
+ import { readCheckEvidence } from "../../workspace/trust/check-evidence";
18
+ import { signOpenReports } from "../../workspace/trust/open-evidence";
19
+ import { parseArgs } from "../parse-args";
20
+ import type { CommandContext } from "../registry";
21
+ import type { MergeRequestJob, PrForge } from "../../pr-forge";
22
+
23
+ const forge = vi.hoisted(() => ({ current: undefined as unknown }));
24
+ vi.mock("../../pr-forge", async (actual) => ({ ...(await actual<typeof import("../../pr-forge")>()), forgeFromEnv: () => forge.current }));
25
+
26
+ const { runCiEvidence } = await import("./ci-evidence");
27
+
28
+ function git(cwd: string, ...args: string[]): string {
29
+ return execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@example.invalid", "-c", "init.defaultBranch=main", ...args], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
30
+ }
31
+
32
+ /** A repository whose base lists `ci`'s key as a runner, and a merge request's head on a branch beside it. */
33
+ function repo(): { dir: string; base: string; head: string; pem: string } {
34
+ const dir = mkdtempSync(join(tmpdir(), "chant-4914-"));
35
+ const { privateKey } = generateKeyPairSync("ed25519");
36
+ const pem = privateKey.export({ format: "pem", type: "pkcs8" }).toString();
37
+ git(dir, "init", "--quiet");
38
+ mkdirSync(join(dir, ".chant"));
39
+ writeFileSync(join(dir, ".chant/trust.json"), JSON.stringify({ schema: 1, runners: [{ principal: "ci", class: "runner", key: loadRunnerKey(pem).publicKey }] }));
40
+ writeFileSync(join(dir, "main.tf"), "# base\n");
41
+ git(dir, "add", ".");
42
+ git(dir, "commit", "--quiet", "-m", "base");
43
+ const base = git(dir, "rev-parse", "HEAD");
44
+ git(dir, "checkout", "--quiet", "-b", "change");
45
+ writeFileSync(join(dir, "main.tf"), "# change\n");
46
+ git(dir, "commit", "--quiet", "-am", "change");
47
+ const head = git(dir, "rev-parse", "HEAD");
48
+ git(dir, "checkout", "--quiet", "main");
49
+ return { dir, base, head, pem };
50
+ }
51
+
52
+ /** A GitLab client with the merge requests' jobs, each job's artifact files, and the merge requests from a fork. */
53
+ function gitlab(jobs: MergeRequestJob[], artifacts: Record<number, Record<string, string>>, forks: number[] = []) {
54
+ const asked: string[] = [];
55
+ const client = {
56
+ kind: "gitlab",
57
+ async mergeRequestJobs(_branch: string, job: string) {
58
+ asked.push(job);
59
+ return jobs;
60
+ },
61
+ async openPullRequests(base: string) {
62
+ return jobs.map((j) => ({ number: j.pr, head: `mr-${j.pr}`, headSha: j.head, base, fork: forks.includes(j.pr) }));
63
+ },
64
+ async jobArtifact(id: number, path: string) {
65
+ return artifacts[id]?.[path];
66
+ },
67
+ } as unknown as PrForge;
68
+ return { client, asked };
69
+ }
70
+
71
+ const PLAN = JSON.stringify({ version: 1, policy: { result: "passed" } });
72
+ const CHECK = JSON.stringify({ version: 1, hooks: [{ name: "lint", exit: 0, outcome: "passed" }, { name: "tests", exit: 1, outcome: "failed" }] });
73
+
74
+ afterEach(() => {
75
+ vi.restoreAllMocks();
76
+ delete process.env.CHANT_RUNNER_KEY;
77
+ });
78
+
79
+ async function run(dir: string, argv: string[]): Promise<number> {
80
+ vi.spyOn(process, "cwd").mockReturnValue(dir);
81
+ vi.spyOn(console, "error").mockImplementation(() => {});
82
+ return runCiEvidence({ args: parseArgs(["ci", "evidence", "sign", ...argv]) } as CommandContext);
83
+ }
84
+
85
+ describe("ci evidence sign --open (#4914)", () => {
86
+ test("signs each open merge request's settled plan job for its head, keeps evidence.json naming it, and signs a head once", async () => {
87
+ const r = repo();
88
+ const g = gitlab(
89
+ [
90
+ { pr: 7, head: r.head, id: 101, status: "success" },
91
+ { pr: 8, head: r.head, id: 102, status: "running" },
92
+ ],
93
+ { 101: { ".chant/pr/pr-plan.json": PLAN } },
94
+ );
95
+ forge.current = g.client;
96
+ process.env.CHANT_RUNNER_KEY = r.pem;
97
+ const out = join(r.dir, ".chant/evidence/plan");
98
+ const argv = ["--open", "--job", "plan", "--from-report", ".chant/pr", "--base", r.base, "--branch", "main", "-o", out, "--no-push"];
99
+ expect(await run(r.dir, argv)).toBe(0);
100
+ expect(g.asked).toEqual(["plan"]);
101
+ const kept = JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8"));
102
+ expect(kept).toMatchObject({ pr: 7, head: r.head, skipped: [] });
103
+ expect(kept.signed.map((s: { check: string }) => s.check)).toEqual(["plan", "policy"]);
104
+ expect(existsSync(join(out, "8"))).toBe(false);
105
+ expect((await readCheckEvidence(r.dir, r.head, r.base, ["plan", "policy"])).map((v) => v.status)).toEqual(["current", "current"]);
106
+ // The next scheduled pipeline: the head's evidence is current, so nothing is signed again, and the file says it is signed.
107
+ const notes = git(r.dir, "notes", "--ref=refs/notes/chant/evidence", "list");
108
+ expect(await run(r.dir, argv)).toBe(0);
109
+ expect(git(r.dir, "notes", "--ref=refs/notes/chant/evidence", "list")).toBe(notes);
110
+ expect(JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8")).signed.map((s: { check: string; runner: string }) => `${s.check}:${s.runner}`)).toEqual(["plan:ci", "policy:ci"]);
111
+ });
112
+
113
+ test("signs each hook that passed from a check job's artifact, and none of a fork's with --no-forks", async () => {
114
+ const r = repo();
115
+ const g = gitlab(
116
+ [
117
+ { pr: 7, head: r.head, id: 201, status: "failed" },
118
+ { pr: 9, head: r.head, id: 202, status: "success" },
119
+ ],
120
+ { 201: { ".chant/check/check-hooks.json": CHECK }, 202: { ".chant/check/check-hooks.json": CHECK } },
121
+ [9],
122
+ );
123
+ forge.current = g.client;
124
+ process.env.CHANT_RUNNER_KEY = r.pem;
125
+ const out = join(r.dir, ".chant/evidence/check");
126
+ expect(await run(r.dir, ["--open", "--job", "check", "--from-report", ".chant/check", "--base", r.base, "--branch", "main", "-o", out, "--no-push", "--no-forks"])).toBe(0);
127
+ const kept = JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8"));
128
+ expect(kept.signed.map((s: { check: string }) => s.check)).toEqual(["lint"]);
129
+ expect(kept.skipped).toEqual([{ check: "tests", reason: "the hook did not pass in the check job" }]);
130
+ expect(existsSync(join(out, "9"))).toBe(false);
131
+ });
132
+
133
+ test("refuses what it cannot sign for: no job, no output, a fixed head", async () => {
134
+ const r = repo();
135
+ forge.current = gitlab([], {}).client;
136
+ expect(await run(r.dir, ["--open", "--from-report", ".chant/pr", "-o", "x", "--branch", "main"])).toBe(1);
137
+ expect(await run(r.dir, ["--open", "--job", "plan", "--from-report", ".chant/pr", "--branch", "main"])).toBe(1);
138
+ expect(await run(r.dir, ["--open", "--job", "plan", "--from-report", ".chant/pr", "-o", "x", "--branch", "main", "--at", "HEAD"])).toBe(1);
139
+ });
140
+ });
141
+
142
+ describe("signOpenReports (#4914)", () => {
143
+ test("a job that left no report, or whose head does not fetch, is said and signs nothing", async () => {
144
+ const out = mkdtempSync(join(tmpdir(), "chant-4914-open-"));
145
+ const g = gitlab(
146
+ [
147
+ { pr: 1, head: "a".repeat(40), id: 1, status: "success" },
148
+ { pr: 2, head: "b".repeat(40), id: 2, status: "success" },
149
+ ],
150
+ { 2: { ".chant/pr/pr-plan.json": PLAN } },
151
+ );
152
+ const sign = vi.fn();
153
+ const { done } = await signOpenReports({ forge: g.client, branch: "main", job: "plan", artifactDir: ".chant/pr/", out, fetchHead: () => false, sign });
154
+ expect(done.map((d) => [d.pr, d.skipped])).toEqual([
155
+ [1, "the plan job left no report under .chant/pr"],
156
+ [2, `the head ${"b".repeat(12)} did not fetch`],
157
+ ]);
158
+ expect(sign).not.toHaveBeenCalled();
159
+ });
160
+
161
+ test("a forge that cannot list merge request jobs is refused", async () => {
162
+ await expect(signOpenReports({ forge: { kind: "github" } as PrForge, branch: "main", job: "plan", artifactDir: ".chant/pr", out: "x", fetchHead: () => true, sign: vi.fn() })).rejects.toThrow(/it is for GitLab/);
163
+ });
164
+ });
@@ -6,18 +6,40 @@
6
6
  *
7
7
  * - `sign --check-id <id>[,<id>...]` signs that each check passed at `--at`
8
8
  * (default `HEAD`), with the runner key in `--key <file>` or
9
- * `CHANT_RUNNER_KEY`, and pushes the notes unless `--no-push`.
9
+ * `CHANT_RUNNER_KEY`, or keyless from the job's OIDC identity with
10
+ * `CHANT_RUNNER_IDENTITY=oidc` (#4869), and pushes the notes unless
11
+ * `--no-push`.
10
12
  * - `sign --from-report <dir> --result <result>` is the plan note job's
11
13
  * form: it signs `plan` when the plan job succeeded and left a report in
12
14
  * `<dir>`, and `policy` when the policy evaluated inside that plan did not
13
15
  * deny it (a `pr-plan.json`'s `policy`, a plan note hand-off's overrides).
14
16
  * It writes `evidence.json` in `<dir>`, which `pr-post` reads to say in the
15
17
  * note which checks were signed.
18
+ * - `sign --from-report <dir>` on a check job's report (#4935), a
19
+ * `check-hooks.json` from `chant ci check`, is the `check-evidence` job's
20
+ * form: it signs each hook that passed, by name, with the runs as its
21
+ * claim, as `ci check` with a runner identity signs them. A hook skipped on
22
+ * local evidence did not pass here and is not signed. With `--result`, a
23
+ * check job that neither succeeded nor failed signs nothing.
24
+ * - `sign --open --job <job> --from-report <dir> -o <out>` (#4914) is the
25
+ * GitLab signing job's form, in a pipeline of the target branch: for each
26
+ * open merge request it reads the report from the newest pipeline's
27
+ * `<job>` artifact, fetches the head and signs it as `--from-report`
28
+ * does, skipping a check already signed for the head's tree, and keeps
29
+ * `<out>/<iid>/evidence.json` for the note job. No job of a merge request
30
+ * pipeline, which the change's own files build, holds the key.
31
+ * - `sign --from-job <job> --check-id <id>[,<id>...] [--claims <dir>]`
32
+ * (#4926) is a wave's evidence job's form: it reads the job of that name
33
+ * in this run through the forge, refuses one of another run or commit,
34
+ * and signs each check whose step (named in `CHANT_EVIDENCE_SOURCES`; on
35
+ * GitLab, whose jobs have no steps, the job) the forge reports passed and
36
+ * whose claim file in `<dir>` says so. Each statement names the run, job
37
+ * and step it relied on (`source`).
16
38
  * - `verify --check-id <id>[,<id>...]` reads the evidence for `--at`'s tree
17
39
  * and verifies it against the runner keys at `--base`; exits 1 when one
18
40
  * is not current.
19
41
  *
20
- * Without a runner key, `sign` signs nothing and says so: a project that
42
+ * Without a runner identity, `sign` signs nothing and says so: a project that
21
43
  * declares no runner identity gets the same job it had.
22
44
  *
23
45
  * `--local` (#4868) is the developer's or agent session's form: `sign
@@ -25,7 +47,8 @@
25
47
  * `local.keys` at base lists, and pushes `refs/notes/chant/local-evidence`;
26
48
  * `verify --local` says whether CI would skip each check on that evidence.
27
49
  */
28
- import { readFileSync, writeFileSync } from "node:fs";
50
+ import { execFileSync, spawnSync } from "node:child_process";
51
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
29
52
  import { join } from "node:path";
30
53
  import { CHANT_EXIT } from "../../exit-codes";
31
54
  import { formatError } from "../format";
@@ -34,9 +57,11 @@ import { gitRoot } from "../../workspace/record-source";
34
57
  import { resolveBase } from "../../workspace/trust/provenance";
35
58
  import {
36
59
  CHECK_EVIDENCE_KEY_ENV,
60
+ noRunnerIdentity,
37
61
  readCheckEvidence,
38
62
  recordChecks,
39
- runnerKeyEvidenceSigner,
63
+ RUNNER_IDENTITY_ENV,
64
+ runnerEvidenceSigner,
40
65
  signChecks,
41
66
  type EvidenceSigner,
42
67
  } from "../../workspace/trust/check-evidence";
@@ -44,6 +69,8 @@ import { CHECK_EVIDENCE_FILE, LOCAL_EVIDENCE_KEY_ENV, planReportChecks, type Che
44
69
 
45
70
  const USAGE =
46
71
  "chant ci evidence sign (--check-id <id>[,<id>...] | --from-report <dir> --result <result>) [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
72
+ " chant ci evidence sign --open --job <job> --from-report <dir> -o <out> [--branch <branch>] [--base <rev>] [--key <file>] [--no-push] [--json]\n" +
73
+ " chant ci evidence sign --from-job <job> --check-id <id>[,<id>...] [--claims <dir>] [--at <rev>] [--base <rev>] [--key <file>] [--no-push] [--json]\n" +
47
74
  " chant ci evidence sign --local --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
48
75
  " chant ci evidence verify [--local] --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--json]";
49
76
 
@@ -106,48 +133,220 @@ async function verifyLocal(ctx: CommandContext, repo: string, base: string, at:
106
133
  return verdicts.every((v) => v.status === "accepted") ? CHANT_EXIT.done : CHANT_EXIT.failed;
107
134
  }
108
135
 
136
+ /**
137
+ * `sign --from-job <job>` (#4926): the wave's evidence job, signing each
138
+ * named check whose step in that job of this run and commit the forge
139
+ * reports as passed (../../ci-evidence-from-job.ts). Exits 1 when the job is
140
+ * another run's or commit's.
141
+ */
142
+ async function signFromJobCommand(ctx: CommandContext, repo: string, base: string): Promise<number> {
143
+ const { args } = ctx;
144
+ const checks = idsOf(args.checkId);
145
+ if (checks.length === 0) return usage("sign --from-job needs --check-id <id>[,<id>...], the checks the job ran");
146
+ if (args.fromReport) return usage("--from-job and --from-report are two ways to sign; pass one");
147
+ const pem = args.key ? readFileSync(args.key, "utf-8") : undefined;
148
+ try {
149
+ const { forgeTargetFromEnv } = await import("../../pr-forge");
150
+ const { forgeReadsFor } = await import("../../pr-forge-reads");
151
+ const { signFromJob } = await import("../../ci-evidence-from-job");
152
+ const reads = forgeReadsFor(forgeTargetFromEnv(process.env));
153
+ const done = await signFromJob({ repo, base, fromJob: args.fromJob!, checks, ...(args.claims ? { claims: args.claims } : {}), ...(args.at ? { at: args.at } : {}), reads, ...(pem ? { key: pem } : {}), push: !args.noPush });
154
+ if ("refused" in done) {
155
+ console.error(formatError({ message: `ci evidence: ${done.refused}`, hint: USAGE }));
156
+ return CHANT_EXIT.failed;
157
+ }
158
+ if (args.json) console.log(JSON.stringify({ signed: done.signed, skipped: done.skipped }, null, 2));
159
+ return CHANT_EXIT.done;
160
+ } catch (err) {
161
+ console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
162
+ return CHANT_EXIT.failed;
163
+ }
164
+ }
165
+
109
166
  async function sign(ctx: CommandContext, repo: string, base: string, at: string): Promise<number> {
110
167
  const { args } = ctx;
168
+ if (args.open && args.fromJob) return usage("--open and --from-job are two ways to sign; pass one");
169
+ if (args.open) return signOpen(ctx, repo, base);
170
+ if (args.fromJob) return signFromJobCommand(ctx, repo, base);
111
171
  const fromReport = args.fromReport;
112
172
  if (!fromReport && idsOf(args.checkId).length === 0) return usage("sign needs --check-id <id>, or --from-report <dir> in a plan note job");
113
173
  const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[CHECK_EVIDENCE_KEY_ENV];
174
+ let wanted: Array<{ check: string; claim?: Buffer | string }> | undefined;
175
+ if (!fromReport) {
176
+ const claim = args.claim ? readFileSync(args.claim) : undefined;
177
+ wanted = idsOf(args.checkId).map((check) => ({ check, ...(claim ? { claim } : {}) }));
178
+ }
179
+ const done = await signChecksOf(repo, base, at, { ...(fromReport ? { fromReport } : {}), ...(wanted ? { wanted } : {}), ...(args.planResult ? { result: args.planResult } : {}), pem, push: !args.noPush });
180
+ if ("usage" in done) return usage(done.usage);
181
+ if (fromReport) writeFileSync(join(fromReport, CHECK_EVIDENCE_FILE), JSON.stringify(done.note, null, 2) + "\n");
182
+ if (args.json) console.log(JSON.stringify(done.note, null, 2));
183
+ return done.code;
184
+ }
185
+
186
+ /**
187
+ * Sign the checks of a report directory (`fromReport`) or the named ones
188
+ * (`wanted`) at `at`, against the runner identities at `base`. With
189
+ * `skipCurrent` (#4914), a check whose current evidence the notes already
190
+ * hold is not signed again and is listed as signed by that runner, so a
191
+ * pipeline that runs on every schedule signs each head once.
192
+ */
193
+ async function signChecksOf(
194
+ repo: string,
195
+ base: string,
196
+ at: string,
197
+ opts: { fromReport?: string; wanted?: Array<{ check: string; claim?: Buffer | string }>; result?: string; pem?: string; push: boolean; skipCurrent?: boolean },
198
+ ): Promise<{ note: CheckEvidenceNote; code: number } | { usage: string }> {
199
+ const { fromReport, pem } = opts;
200
+ const identity = pem !== undefined && pem !== "" ? "key" : process.env[RUNNER_IDENTITY_ENV] ? "oidc" : undefined;
114
201
  const note: CheckEvidenceNote = { signed: [], skipped: [] };
115
202
  let wanted: Array<{ check: string; claim?: Buffer | string }>;
116
- if (fromReport) {
117
- const decided = planReportChecks(fromReport, args.planResult);
203
+ if (fromReport && isCheckReportDir(fromReport)) {
204
+ // #4935: a check job's report, each passed hook signed by name.
205
+ const decided = await checkReportChecks(fromReport, opts.result);
206
+ if ("error" in decided) return { usage: decided.error };
207
+ wanted = decided.sign;
208
+ note.skipped.push(...decided.skipped);
209
+ } else if (fromReport) {
210
+ const decided = planReportChecks(fromReport, opts.result);
118
211
  wanted = decided.sign;
119
212
  note.skipped.push(...decided.skipped);
120
213
  } else {
121
- const claim = args.claim ? readFileSync(args.claim) : undefined;
122
- wanted = idsOf(args.checkId).map((check) => ({ check, ...(claim ? { claim } : {}) }));
214
+ wanted = opts.wanted ?? [];
123
215
  }
124
- const finish = (code: number): number => {
125
- if (fromReport) writeFileSync(join(fromReport, CHECK_EVIDENCE_FILE), JSON.stringify(note, null, 2) + "\n");
126
- if (args.json) console.log(JSON.stringify(note, null, 2));
127
- return code;
128
- };
129
- if (!pem) {
130
- note.skipped.push(...wanted.map((w) => ({ check: w.check, reason: `no runner key: ${CHECK_EVIDENCE_KEY_ENV} is not set` })));
131
- console.error(`ci evidence: no runner key in ${CHECK_EVIDENCE_KEY_ENV}, so no check was signed`);
132
- return finish(CHANT_EXIT.done);
216
+ if (!identity) {
217
+ note.skipped.push(...wanted.map((w) => ({ check: w.check, reason: noRunnerIdentity() })));
218
+ console.error(`ci evidence: ${noRunnerIdentity()}, so no check was signed`);
219
+ return { note, code: CHANT_EXIT.done };
133
220
  }
134
221
  let signer: EvidenceSigner;
135
222
  try {
136
- signer = runnerKeyEvidenceSigner(repo, base, pem);
223
+ signer = (await runnerEvidenceSigner(repo, base, pem ? { key: pem } : {}))!;
137
224
  } catch (err) {
138
225
  console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
139
- return finish(CHANT_EXIT.failed);
226
+ return { note, code: CHANT_EXIT.failed };
140
227
  }
141
228
  for (const s of note.skipped) console.error(`ci evidence: ${s.check} not signed: ${s.reason}`);
142
- if (wanted.length === 0) return finish(CHANT_EXIT.done);
143
- const signed = signChecks(repo, at, wanted, signer);
144
- const pushed = await recordChecks(repo, signed, { push: !args.noPush });
229
+ if (opts.skipCurrent && wanted.length > 0) {
230
+ const { tree } = commitTree(repo, at);
231
+ const current = (await readCheckEvidence(repo, at, base, wanted.map((w) => w.check))).filter((v) => v.status === "current");
232
+ for (const v of current) {
233
+ note.signed.push({ check: v.check, runner: v.runner, commit: v.commit, tree });
234
+ console.error(`ci evidence: ${v.check} at ${at.slice(0, 12)} is already signed by ${v.runner}`);
235
+ }
236
+ const kept = new Set(current.map((v) => v.check));
237
+ wanted = wanted.filter((w) => !kept.has(w.check));
238
+ }
239
+ if (wanted.length === 0) return { note, code: CHANT_EXIT.done };
240
+ const signed = await signChecks(repo, at, wanted, signer);
241
+ const pushed = await recordChecks(repo, signed, { push: opts.push });
145
242
  for (const s of signed) {
146
243
  note.signed.push({ check: s.check, runner: s.runner, commit: s.commit, tree: s.tree });
147
244
  console.error(`ci evidence: signed ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}`);
148
245
  }
149
- if (!args.noPush && !pushed.pushed && pushed.pushWarning) console.error(`ci evidence: the evidence is attached here, and the push did not land: ${pushed.pushWarning}`);
150
- return finish(CHANT_EXIT.done);
246
+ if (opts.push && !pushed.pushed && pushed.pushWarning) console.error(`ci evidence: the evidence is attached here, and the push did not land: ${pushed.pushWarning}`);
247
+ return { note, code: CHANT_EXIT.done };
248
+ }
249
+
250
+ /** A commit's full sha and tree, read with git. */
251
+ function commitTree(repo: string, rev: string): { commit: string; tree: string } {
252
+ const read = (spec: string) => execFileSync("git", ["rev-parse", "--verify", spec], { cwd: repo, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
253
+ return { commit: read(`${rev}^{commit}`), tree: read(`${rev}^{tree}`) };
254
+ }
255
+
256
+ /**
257
+ * `sign --open --job <job> --from-report <dir> -o <out>` (#4914): in a
258
+ * GitLab pipeline of the target branch, sign each open merge request's
259
+ * settled `job` from its artifact (../../workspace/trust/open-evidence.ts),
260
+ * against the policy at `--base` (the generated job passes the branch's
261
+ * commit). The branch is `--branch`, else the pipeline's own. Exits 0 once
262
+ * each merge request is signed or said, and 1 when the job's runner
263
+ * identity is not one the policy at base lists.
264
+ */
265
+ async function signOpen(ctx: CommandContext, repo: string, base: string): Promise<number> {
266
+ const { args } = ctx;
267
+ if (!args.ciJob || !/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(args.ciJob)) return usage("sign --open needs the job to sign for, by name: --job plan");
268
+ if (!args.fromReport) return usage("sign --open needs the job's report directory as its artifact keeps it: --from-report .chant/pr");
269
+ if (!args.output) return usage("sign --open needs where to keep each merge request's evidence.json: -o .chant/evidence/<job>");
270
+ if (args.checkId || args.at || args.planResult) return usage("sign --open finds each merge request's head and its job's result itself, so it takes no --check-id, --at or --result");
271
+ const branch = args.branch ?? process.env.CI_COMMIT_BRANCH;
272
+ if (!branch) return usage("sign --open signs for the merge requests into a branch: run it in a branch pipeline, or pass --branch <branch>");
273
+ const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[CHECK_EVIDENCE_KEY_ENV];
274
+ const { forgeFromEnv } = await import("../../pr-forge");
275
+ const { signOpenReports } = await import("../../workspace/trust/open-evidence");
276
+ // The notes there are the ones to skip a head already signed by, and to add to.
277
+ spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", "+refs/notes/chant/evidence:refs/notes/chant/evidence"], { cwd: repo, encoding: "utf-8" });
278
+ let failed = false;
279
+ let done: Awaited<ReturnType<typeof signOpenReports>>;
280
+ try {
281
+ done = await signOpenReports({
282
+ forge: forgeFromEnv("gitlab"),
283
+ branch,
284
+ job: args.ciJob,
285
+ artifactDir: args.fromReport,
286
+ out: args.output,
287
+ ...(args.noForks ? { noForks: true } : {}),
288
+ fetchHead: (pr, head) => fetchMergeRequestHead(repo, pr, head),
289
+ sign: async (dir, head, result) => {
290
+ const r = await signChecksOf(repo, base, head, { fromReport: dir, result, ...(pem ? { pem } : {}), push: !args.noPush, skipCurrent: true });
291
+ if ("usage" in r) throw new Error(r.usage);
292
+ if (r.code !== CHANT_EXIT.done) failed = true;
293
+ return r.note;
294
+ },
295
+ });
296
+ } catch (err) {
297
+ console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
298
+ return CHANT_EXIT.failed;
299
+ }
300
+ for (const w of done.warnings) console.error(`ci evidence: ${w}`);
301
+ for (const d of done.done) {
302
+ if (d.skipped) console.error(`ci evidence: !${d.pr}: ${d.skipped}`);
303
+ else console.error(`ci evidence: !${d.pr} at ${d.head.slice(0, 12)}: signed ${d.note!.signed.map((s) => s.check).join(", ") || "nothing"}`);
304
+ }
305
+ if (done.done.length === 0) console.error(`ci evidence: no open merge request into ${branch} has a ${args.ciJob} job`);
306
+ if (args.json) console.log(JSON.stringify(done.done, null, 2));
307
+ return failed ? CHANT_EXIT.failed : CHANT_EXIT.done;
308
+ }
309
+
310
+ /** Fetch merge request `pr`'s head (`refs/merge-requests/<iid>/head`, a fork's too), else the commit itself; true once it is here. */
311
+ function fetchMergeRequestHead(repo: string, pr: number, head: string): boolean {
312
+ const here = () => spawnSync("git", ["cat-file", "-e", `${head}^{commit}`], { cwd: repo }).status === 0;
313
+ if (here()) return true;
314
+ spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", `refs/merge-requests/${pr}/head`], { cwd: repo, encoding: "utf-8" });
315
+ if (here()) return true;
316
+ spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", head], { cwd: repo, encoding: "utf-8" });
317
+ return here();
318
+ }
319
+
320
+ /** Whether `dir` holds a check job's report and no plan report (#4935). */
321
+ function isCheckReportDir(dir: string): boolean {
322
+ return existsSync(join(dir, "check-hooks.json")) && !existsSync(join(dir, "pr-plan.json")) && !existsSync(join(dir, "pr-plan-note.json"));
323
+ }
324
+
325
+ /**
326
+ * The hooks to sign from a check job's report (#4935): each hook whose every
327
+ * run passed, with its runs as the claim, as the check runner signs them
328
+ * (../../components/check-steps.ts). The report is the check job's, which ran
329
+ * the change's code, so it is read as data: a hook with no name or outcome is
330
+ * left out. A job `result` other than success or failure signs none.
331
+ */
332
+ async function checkReportChecks(dir: string, result: string | undefined): Promise<{ sign: Array<{ check: string; claim: string }>; skipped: CheckEvidenceNote["skipped"] } | { error: string }> {
333
+ const { CHECK_HOOKS_REPORT_FILE, passedCheckHooks } = await import("../../components/check-hooks");
334
+ let doc: unknown;
335
+ try {
336
+ doc = JSON.parse(readFileSync(join(dir, CHECK_HOOKS_REPORT_FILE), "utf-8"));
337
+ } catch (err) {
338
+ return { error: `--from-report ${dir}: ${CHECK_HOOKS_REPORT_FILE} does not read: ${err instanceof Error ? err.message : String(err)}` };
339
+ }
340
+ const hooks = doc && typeof doc === "object" && Array.isArray((doc as { hooks?: unknown }).hooks) ? ((doc as { hooks: unknown[] }).hooks as Array<Record<string, unknown>>) : undefined;
341
+ if (!hooks) return { error: `--from-report ${dir}: ${CHECK_HOOKS_REPORT_FILE} lists no hooks` };
342
+ const runs = hooks.filter((h) => h && typeof h.name === "string" && h.name.length > 0 && h.name.length <= 200 && (h.outcome === "passed" || h.outcome === "failed" || h.outcome === "skipped"));
343
+ const passed = passedCheckHooks(runs as unknown as Parameters<typeof passedCheckHooks>[0]);
344
+ if (result !== undefined && result !== "success" && result !== "failure") {
345
+ return { sign: [], skipped: passed.map((p) => ({ check: p.check, reason: `the check job's result is ${result}` })) };
346
+ }
347
+ const signed = new Set(passed.map((p) => p.check));
348
+ const skipped = [...new Set(runs.map((h) => h.name as string))].filter((n) => !signed.has(n)).map((check) => ({ check, reason: "the hook did not pass in the check job" }));
349
+ return { sign: passed.map((p) => ({ check: p.check, claim: JSON.stringify(p.runs) })), skipped };
151
350
  }
152
351
 
153
352
  async function verify(ctx: CommandContext, repo: string, base: string, at: string): Promise<number> {
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * `chant ci forge-check [--env <env>] [--member <name>] [--forge <forge>]
3
- * [--repo <owner/name>] [--branch <default>] [--require-clouds] [--json]`
4
- * (#4608): read the live forge, the clouds and Pulumi Cloud against the
5
- * pull-request pipelines `ci.identity.cloud` gives the workspace, one row
6
- * per expected setting. Read-only. Exits chant's `failed` (1) on a
3
+ * [--repo <owner/name>] [--branch <default>] [--require-clouds]
4
+ * [--ref-gate-status] [--json]` (#4608): read the live forge, the clouds and
5
+ * Pulumi Cloud against the pull-request pipelines `ci.identity.cloud` gives
6
+ * the workspace, one row per expected setting. With `--ref-gate-status`
7
+ * (#4913), for pipelines built with it, the default branch also requires
8
+ * the ref gate's status, named as the policy at `origin/<default>` (else
9
+ * `HEAD`) names it. Read-only. Exits chant's `failed` (1) on a
7
10
  * mismatch, or with --require-clouds on a cloud left unchecked; `done` (0)
8
11
  * otherwise. See ../../forge-check/index.ts.
9
12
  */
@@ -12,7 +15,7 @@ import type { CloudIdentityDeclaration } from "../../ci-identity";
12
15
  import type { ForgeFetch } from "../../pr-forge";
13
16
  import type { CommandContext } from "../registry";
14
17
 
15
- const USAGE = "chant ci forge-check [--env <env>] [--member <name>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--branch <default>] [--require-clouds] [--json]";
18
+ const USAGE = "chant ci forge-check [--env <env>] [--member <name>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--branch <default>] [--require-clouds] [--ref-gate-status] [--json]";
16
19
 
17
20
  /** The environment chant's generated pull-request pipelines default to. */
18
21
  const DEFAULT_ENV = "production";
@@ -62,29 +65,39 @@ export async function runCiForgeCheck(ctx: CommandContext): Promise<number> {
62
65
  });
63
66
  const words = activeProductWords();
64
67
  const host = target.host;
68
+ // #4913: with --ref-gate-status the default branch requires the ref gate's status too, named as the policy names it.
69
+ let gate: { status?: string; note?: string; problem?: string } = {};
70
+ const statusFor = args.refGateStatus ? (await import("../../ref-gate-rules")).refGateStatusFor : undefined;
65
71
  const result = await forgeCheck(
66
72
  {
67
73
  target,
68
74
  words,
69
75
  ...(args.requireClouds ? { requireClouds: true } : {}),
70
- contract: (live) =>
71
- pipelineContract({
76
+ contract: (live) => {
77
+ const defaultBranch = args.branch ?? live.defaultBranch ?? "main";
78
+ if (statusFor) gate = statusFor(found?.dir ?? process.cwd(), defaultBranch);
79
+ const status = gate.status;
80
+ return pipelineContract({
72
81
  forge: target.kind,
73
82
  repository: {
74
83
  host,
75
84
  path: live.path ?? target.repo,
76
- defaultBranch: args.branch ?? live.defaultBranch ?? "main",
85
+ defaultBranch,
77
86
  ...(live.ownerId ? { ownerId: live.ownerId } : {}),
78
87
  ...(live.repoId ? { repoId: live.repoId } : {}),
79
88
  },
80
89
  pipelines,
81
90
  words,
82
- }),
91
+ ...(status ? { refGateStatus: status } : {}),
92
+ });
93
+ },
83
94
  },
84
95
  { fetch: globalThis.fetch as unknown as ForgeFetch, env: process.env },
85
96
  );
97
+ if (gate.problem) return fail(`--ref-gate-status: ${gate.problem}`);
86
98
  if (args.json) console.log(JSON.stringify(result, null, 2));
87
99
  else console.log(describeForgeCheck(result));
100
+ if (gate.note) console.error(`ci forge-check: ${gate.note}`);
88
101
  if (!decl) console.error("ci forge-check: no ci.identity.cloud in the workspace declaration, so no trust was checked");
89
102
  else if (pipelines.length === 0) console.error(`ci forge-check: no rule of ci.identity.cloud covers environment ${env}, so no trust was checked`);
90
103
  return forgeCheckExit(result);