@intentius/chant 0.124.55 → 0.124.57

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 (419) hide show
  1. package/dist/ci-agent.d.ts.map +1 -1
  2. package/dist/ci-agent.js +1 -2
  3. package/dist/ci-audit/attribution.d.ts +111 -0
  4. package/dist/ci-audit/attribution.d.ts.map +1 -0
  5. package/dist/ci-audit/attribution.js +194 -0
  6. package/dist/ci-audit/audit-log.d.ts +144 -0
  7. package/dist/ci-audit/audit-log.d.ts.map +1 -0
  8. package/dist/ci-audit/audit-log.js +149 -0
  9. package/dist/ci-audit/index.d.ts +12 -0
  10. package/dist/ci-audit/index.d.ts.map +1 -0
  11. package/dist/ci-audit/index.js +11 -0
  12. package/dist/ci-audit/unrecorded.d.ts +74 -0
  13. package/dist/ci-audit/unrecorded.d.ts.map +1 -0
  14. package/dist/ci-audit/unrecorded.js +95 -0
  15. package/dist/ci-audit.d.ts +3 -0
  16. package/dist/ci-audit.d.ts.map +1 -0
  17. package/dist/ci-audit.js +2 -0
  18. package/dist/ci-control.d.ts.map +1 -1
  19. package/dist/ci-control.js +3 -4
  20. package/dist/ci-estate.d.ts +24 -0
  21. package/dist/ci-estate.d.ts.map +1 -1
  22. package/dist/ci-estate.js +1 -2
  23. package/dist/ci-identity.d.ts.map +1 -1
  24. package/dist/ci-identity.js +2 -3
  25. package/dist/ci-job-guard.d.ts +139 -0
  26. package/dist/ci-job-guard.d.ts.map +1 -0
  27. package/dist/ci-job-guard.js +287 -0
  28. package/dist/ci-jobs.d.ts +7 -0
  29. package/dist/ci-jobs.d.ts.map +1 -1
  30. package/dist/ci-jobs.js +7 -0
  31. package/dist/ci-product-words.d.ts +7 -1
  32. package/dist/ci-product-words.d.ts.map +1 -1
  33. package/dist/ci-product-words.js +38 -4
  34. package/dist/ci-product.d.ts +35 -0
  35. package/dist/ci-product.d.ts.map +1 -1
  36. package/dist/ci-product.js +38 -4
  37. package/dist/ci-respond-run.d.ts +73 -0
  38. package/dist/ci-respond-run.d.ts.map +1 -0
  39. package/dist/ci-respond-run.js +247 -0
  40. package/dist/ci-respond.d.ts +189 -0
  41. package/dist/ci-respond.d.ts.map +1 -0
  42. package/dist/ci-respond.js +285 -0
  43. package/dist/cli/handlers/audit-log.d.ts +12 -0
  44. package/dist/cli/handlers/audit-log.d.ts.map +1 -0
  45. package/dist/cli/handlers/audit-log.js +81 -0
  46. package/dist/cli/handlers/build.d.ts +7 -0
  47. package/dist/cli/handlers/build.d.ts.map +1 -1
  48. package/dist/cli/handlers/build.js +81 -0
  49. package/dist/cli/handlers/ci-check-job.d.ts +11 -0
  50. package/dist/cli/handlers/ci-check-job.d.ts.map +1 -0
  51. package/dist/cli/handlers/ci-check-job.js +27 -0
  52. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  53. package/dist/cli/handlers/ci-check.js +38 -9
  54. package/dist/cli/handlers/e2e-safe-run.d.ts +12 -0
  55. package/dist/cli/handlers/e2e-safe-run.d.ts.map +1 -0
  56. package/dist/cli/handlers/e2e-safe-run.js +23 -0
  57. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  58. package/dist/cli/handlers/lifecycle.js +14 -0
  59. package/dist/cli/handlers/pr.d.ts +5 -0
  60. package/dist/cli/handlers/pr.d.ts.map +1 -1
  61. package/dist/cli/handlers/pr.js +346 -36
  62. package/dist/cli/handlers/run-wave.js +89 -1
  63. package/dist/cli/main.d.ts.map +1 -1
  64. package/dist/cli/main.js +56 -2
  65. package/dist/cli/parse-args.d.ts.map +1 -1
  66. package/dist/cli/parse-args.js +107 -0
  67. package/dist/cli/registry.d.ts +38 -0
  68. package/dist/cli/registry.d.ts.map +1 -1
  69. package/dist/components/adoption.d.ts.map +1 -1
  70. package/dist/components/adoption.js +1 -2
  71. package/dist/components/auto-release.d.ts +5 -2
  72. package/dist/components/auto-release.d.ts.map +1 -1
  73. package/dist/components/auto-release.js +9 -4
  74. package/dist/components/capability.d.ts +47 -0
  75. package/dist/components/capability.d.ts.map +1 -1
  76. package/dist/components/capability.js +25 -0
  77. package/dist/components/check-hooks.d.ts +4 -1
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-steps.d.ts +74 -0
  80. package/dist/components/check-steps.d.ts.map +1 -0
  81. package/dist/components/check-steps.js +102 -0
  82. package/dist/components/ci-services.d.ts.map +1 -1
  83. package/dist/components/ci-services.js +1 -2
  84. package/dist/components/deploy-units.d.ts +12 -0
  85. package/dist/components/deploy-units.d.ts.map +1 -1
  86. package/dist/components/deploy-units.js +20 -1
  87. package/dist/components/driver.d.ts +12 -0
  88. package/dist/components/driver.d.ts.map +1 -1
  89. package/dist/components/driver.js +35 -1
  90. package/dist/components/groups.d.ts.map +1 -1
  91. package/dist/components/groups.js +4 -3
  92. package/dist/components/pr-env-ledger.d.ts.map +1 -1
  93. package/dist/components/pr-env-ledger.js +1 -2
  94. package/dist/components/pr-environment.d.ts +1 -1
  95. package/dist/components/pr-environment.d.ts.map +1 -1
  96. package/dist/components/pr-environment.js +1 -1
  97. package/dist/components/pr-pipeline.d.ts +137 -5
  98. package/dist/components/pr-pipeline.d.ts.map +1 -1
  99. package/dist/components/pr-pipeline.js +164 -20
  100. package/dist/components/pr-run.d.ts +8 -0
  101. package/dist/components/pr-run.d.ts.map +1 -1
  102. package/dist/components/pr-run.js +9 -4
  103. package/dist/components/product-pipeline.d.ts +35 -2
  104. package/dist/components/product-pipeline.d.ts.map +1 -1
  105. package/dist/components/product-pipeline.js +24 -5
  106. package/dist/components/row-lease.d.ts +22 -1
  107. package/dist/components/row-lease.d.ts.map +1 -1
  108. package/dist/components/row-lease.js +32 -6
  109. package/dist/components/wave-plan.d.ts +8 -0
  110. package/dist/components/wave-plan.d.ts.map +1 -1
  111. package/dist/components/wave-plan.js +18 -2
  112. package/dist/e2e-harness/bucket.d.ts +21 -0
  113. package/dist/e2e-harness/bucket.d.ts.map +1 -0
  114. package/dist/e2e-harness/bucket.js +61 -0
  115. package/dist/e2e-harness/claim.d.ts +70 -0
  116. package/dist/e2e-harness/claim.d.ts.map +1 -0
  117. package/dist/e2e-harness/claim.js +98 -0
  118. package/dist/e2e-harness/driver.d.ts +64 -0
  119. package/dist/e2e-harness/driver.d.ts.map +1 -0
  120. package/dist/e2e-harness/driver.js +243 -0
  121. package/dist/e2e-harness/forgejo.d.ts +77 -0
  122. package/dist/e2e-harness/forgejo.d.ts.map +1 -0
  123. package/dist/e2e-harness/forgejo.js +205 -0
  124. package/dist/e2e-harness/git.d.ts +32 -0
  125. package/dist/e2e-harness/git.d.ts.map +1 -0
  126. package/dist/e2e-harness/git.js +67 -0
  127. package/dist/e2e-harness/index.d.ts +22 -0
  128. package/dist/e2e-harness/index.d.ts.map +1 -0
  129. package/dist/e2e-harness/index.js +47 -0
  130. package/dist/e2e-harness/jobs.d.ts +8 -0
  131. package/dist/e2e-harness/jobs.d.ts.map +1 -0
  132. package/dist/e2e-harness/jobs.js +34 -0
  133. package/dist/e2e-harness/pins.d.ts +45 -0
  134. package/dist/e2e-harness/pins.d.ts.map +1 -0
  135. package/dist/e2e-harness/pins.js +44 -0
  136. package/dist/e2e-harness/ports.d.ts +113 -0
  137. package/dist/e2e-harness/ports.d.ts.map +1 -0
  138. package/dist/e2e-harness/ports.js +4 -0
  139. package/dist/e2e-harness/reports.d.ts +45 -0
  140. package/dist/e2e-harness/reports.d.ts.map +1 -0
  141. package/dist/e2e-harness/reports.js +57 -0
  142. package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
  143. package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
  144. package/dist/e2e-harness/safe-run-cli.js +43 -0
  145. package/dist/e2e-harness/safe-run.d.ts +61 -0
  146. package/dist/e2e-harness/safe-run.d.ts.map +1 -0
  147. package/dist/e2e-harness/safe-run.js +172 -0
  148. package/dist/e2e-harness/scenario.d.ts +11 -0
  149. package/dist/e2e-harness/scenario.d.ts.map +1 -0
  150. package/dist/e2e-harness/scenario.js +89 -0
  151. package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  152. package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
  153. package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  154. package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  155. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  156. package/dist/e2e-harness/schemas/index.d.ts +191 -0
  157. package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
  158. package/dist/e2e-harness/schemas/index.js +62 -0
  159. package/dist/e2e-harness/stack.d.ts +124 -0
  160. package/dist/e2e-harness/stack.d.ts.map +1 -0
  161. package/dist/e2e-harness/stack.js +207 -0
  162. package/dist/e2e-harness/steps.d.ts +11 -0
  163. package/dist/e2e-harness/steps.d.ts.map +1 -0
  164. package/dist/e2e-harness/steps.js +22 -0
  165. package/dist/e2e-harness.d.ts +3 -0
  166. package/dist/e2e-harness.d.ts.map +1 -0
  167. package/dist/e2e-harness.js +2 -0
  168. package/dist/exit-codes.d.ts +7 -1
  169. package/dist/exit-codes.d.ts.map +1 -1
  170. package/dist/exit-codes.js +7 -1
  171. package/dist/lexicon.d.ts +55 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  174. package/dist/lifecycle/gate-ledger.js +2 -3
  175. package/dist/lifecycle/gated-request.d.ts.map +1 -1
  176. package/dist/lifecycle/gated-request.js +1 -2
  177. package/dist/lifecycle/git.d.ts +39 -3
  178. package/dist/lifecycle/git.d.ts.map +1 -1
  179. package/dist/lifecycle/git.js +223 -15
  180. package/dist/lifecycle/lock-rows.d.ts +23 -0
  181. package/dist/lifecycle/lock-rows.d.ts.map +1 -1
  182. package/dist/lifecycle/lock-rows.js +47 -8
  183. package/dist/lifecycle/query.d.ts.map +1 -1
  184. package/dist/lifecycle/query.js +4 -5
  185. package/dist/lifecycle/release-catalog.d.ts.map +1 -1
  186. package/dist/lifecycle/release-catalog.js +1 -1
  187. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  188. package/dist/lifecycle/release-ledger.js +1 -2
  189. package/dist/lifecycle/release-status.d.ts +20 -0
  190. package/dist/lifecycle/release-status.d.ts.map +1 -1
  191. package/dist/lifecycle/release-status.js +1 -22
  192. package/dist/lifecycle/resource-lock.d.ts +70 -0
  193. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  194. package/dist/lifecycle/resource-lock.js +241 -5
  195. package/dist/lifecycle/wave-plans.d.ts +23 -7
  196. package/dist/lifecycle/wave-plans.d.ts.map +1 -1
  197. package/dist/lifecycle/wave-plans.js +9 -2
  198. package/dist/op/approval-status.d.ts +103 -0
  199. package/dist/op/approval-status.d.ts.map +1 -0
  200. package/dist/op/approval-status.js +197 -0
  201. package/dist/op/gate.js +21 -4
  202. package/dist/op/index.d.ts +1 -1
  203. package/dist/op/index.d.ts.map +1 -1
  204. package/dist/op/index.js +1 -1
  205. package/dist/op/op-waves-capability-spec.d.ts +8 -0
  206. package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
  207. package/dist/op/op-waves-capability-spec.js +21 -0
  208. package/dist/op/op-waves-release-port.js +1 -1
  209. package/dist/op/op-waves-release.d.ts +2 -1
  210. package/dist/op/op-waves-release.d.ts.map +1 -1
  211. package/dist/op/op-waves-release.js +1 -2
  212. package/dist/op/op-waves-run.d.ts +15 -2
  213. package/dist/op/op-waves-run.d.ts.map +1 -1
  214. package/dist/op/op-waves-run.js +195 -31
  215. package/dist/op/op-waves-stand-down.d.ts.map +1 -1
  216. package/dist/op/op-waves-stand-down.js +1 -2
  217. package/dist/op/op-waves.d.ts +53 -0
  218. package/dist/op/op-waves.d.ts.map +1 -1
  219. package/dist/op/op-waves.js +62 -6
  220. package/dist/op/runtime.d.ts +4 -0
  221. package/dist/op/runtime.d.ts.map +1 -1
  222. package/dist/op/runtime.js +2 -3
  223. package/dist/otlp.d.ts.map +1 -1
  224. package/dist/otlp.js +1 -2
  225. package/dist/parallelism.d.ts +17 -0
  226. package/dist/parallelism.d.ts.map +1 -0
  227. package/dist/parallelism.js +33 -0
  228. package/dist/policy-source.d.ts.map +1 -1
  229. package/dist/policy-source.js +1 -2
  230. package/dist/pr-forge.d.ts.map +1 -1
  231. package/dist/pr-forge.js +56 -39
  232. package/dist/pr-loop.d.ts +9 -0
  233. package/dist/pr-loop.d.ts.map +1 -1
  234. package/dist/pr-loop.js +22 -4
  235. package/dist/pr-merge.d.ts +64 -0
  236. package/dist/pr-merge.d.ts.map +1 -0
  237. package/dist/pr-merge.js +78 -0
  238. package/dist/pr-post.d.ts +70 -1
  239. package/dist/pr-post.d.ts.map +1 -1
  240. package/dist/pr-post.js +116 -5
  241. package/dist/pr-report-url.d.ts.map +1 -1
  242. package/dist/pr-report-url.js +1 -2
  243. package/dist/release-floors.d.ts +1 -1
  244. package/dist/release-floors.js +1 -1
  245. package/dist/run-event.d.ts.map +1 -1
  246. package/dist/run-event.js +1 -2
  247. package/dist/scheduled-op-cloud.d.ts +32 -0
  248. package/dist/scheduled-op-cloud.d.ts.map +1 -0
  249. package/dist/scheduled-op-cloud.js +69 -0
  250. package/dist/wave-runtime.mjs +351 -328
  251. package/dist/workspace/ci-lock-grain.d.ts +5 -0
  252. package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
  253. package/dist/workspace/ci-lock-grain.js +1 -7
  254. package/dist/workspace/ci-run.d.ts.map +1 -1
  255. package/dist/workspace/ci-run.js +5 -1
  256. package/dist/workspace/pr-report.schema.json +5 -0
  257. package/package.json +1 -1
  258. package/src/ci-agent.ts +1 -2
  259. package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
  260. package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
  261. package/src/ci-audit/attribution.ts +260 -0
  262. package/src/ci-audit/audit-log.ts +220 -0
  263. package/src/ci-audit/ci-audit.test.ts +175 -0
  264. package/src/ci-audit/index.ts +14 -0
  265. package/src/ci-audit/unrecorded.ts +140 -0
  266. package/src/ci-audit.ts +2 -0
  267. package/src/ci-control.ts +3 -4
  268. package/src/ci-estate.ts +1 -2
  269. package/src/ci-identity-database.test.ts +2 -3
  270. package/src/ci-identity-targets.test.ts +1 -3
  271. package/src/ci-identity.ts +2 -3
  272. package/src/ci-job-guard.test.ts +154 -0
  273. package/src/ci-job-guard.ts +319 -0
  274. package/src/ci-jobs.ts +8 -0
  275. package/src/ci-product-comment-targets.test.ts +45 -0
  276. package/src/ci-product-words.ts +35 -6
  277. package/src/ci-product.ts +55 -4
  278. package/src/ci-respond-run.ts +291 -0
  279. package/src/ci-respond.test.ts +264 -0
  280. package/src/ci-respond.ts +412 -0
  281. package/src/cli/handlers/audit-log.ts +74 -0
  282. package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
  283. package/src/cli/handlers/build.ts +69 -0
  284. package/src/cli/handlers/ci-check-job.test.ts +114 -0
  285. package/src/cli/handlers/ci-check-job.ts +33 -0
  286. package/src/cli/handlers/ci-check.ts +38 -8
  287. package/src/cli/handlers/e2e-safe-run.ts +27 -0
  288. package/src/cli/handlers/lifecycle.ts +13 -0
  289. package/src/cli/handlers/pr-before-merge.test.ts +1 -1
  290. package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
  291. package/src/cli/handlers/pr-endpoint.test.ts +1 -1
  292. package/src/cli/handlers/pr-green.test.ts +1 -1
  293. package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
  294. package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
  295. package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
  296. package/src/cli/handlers/pr-record.test.ts +34 -2
  297. package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
  298. package/src/cli/handlers/pr-waves.test.ts +1 -1
  299. package/src/cli/handlers/pr.test.ts +1 -1
  300. package/src/cli/handlers/pr.ts +311 -32
  301. package/src/cli/handlers/run-wave.ts +79 -1
  302. package/src/cli/main.test.ts +1 -1
  303. package/src/cli/main.ts +56 -2
  304. package/src/cli/parse-args.ts +77 -0
  305. package/src/cli/registry.ts +38 -0
  306. package/src/components/adoption.ts +1 -2
  307. package/src/components/auto-release.test.ts +4 -2
  308. package/src/components/auto-release.ts +9 -5
  309. package/src/components/capability.ts +60 -0
  310. package/src/components/check-hooks.ts +4 -1
  311. package/src/components/check-steps.test.ts +70 -0
  312. package/src/components/check-steps.ts +158 -0
  313. package/src/components/ci-services.ts +1 -2
  314. package/src/components/deploy-units.test.ts +18 -1
  315. package/src/components/deploy-units.ts +26 -1
  316. package/src/components/driver.ts +35 -1
  317. package/src/components/groups.ts +4 -2
  318. package/src/components/plan-flags.test.ts +46 -0
  319. package/src/components/pr-comment-preview-targets.test.ts +34 -0
  320. package/src/components/pr-env-ledger.ts +1 -2
  321. package/src/components/pr-env-run-bundle.test.ts +0 -20
  322. package/src/components/pr-environment.ts +1 -1
  323. package/src/components/pr-pipeline-runners.test.ts +80 -0
  324. package/src/components/pr-pipeline.ts +244 -20
  325. package/src/components/pr-run.ts +17 -6
  326. package/src/components/pr-stale-job.test.ts +34 -0
  327. package/src/components/product-pipeline.ts +50 -8
  328. package/src/components/row-lease.test.ts +61 -1
  329. package/src/components/row-lease.ts +48 -7
  330. package/src/components/wave-plan.ts +18 -2
  331. package/src/e2e-harness/__project__/chant.config.ts +4 -0
  332. package/src/e2e-harness/__project__/src/compose.ts +33 -0
  333. package/src/e2e-harness/bucket.ts +69 -0
  334. package/src/e2e-harness/claim.test.ts +150 -0
  335. package/src/e2e-harness/claim.ts +140 -0
  336. package/src/e2e-harness/driver.test.ts +304 -0
  337. package/src/e2e-harness/driver.ts +294 -0
  338. package/src/e2e-harness/forgejo.ts +267 -0
  339. package/src/e2e-harness/git.ts +96 -0
  340. package/src/e2e-harness/index.ts +49 -0
  341. package/src/e2e-harness/jobs.ts +35 -0
  342. package/src/e2e-harness/pins.ts +52 -0
  343. package/src/e2e-harness/ports.ts +130 -0
  344. package/src/e2e-harness/reports.ts +79 -0
  345. package/src/e2e-harness/safe-run-cli.test.ts +102 -0
  346. package/src/e2e-harness/safe-run-cli.ts +54 -0
  347. package/src/e2e-harness/safe-run.ts +198 -0
  348. package/src/e2e-harness/scenario.ts +89 -0
  349. package/src/e2e-harness/schemas/README.md +62 -0
  350. package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  351. package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
  352. package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  353. package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  354. package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  355. package/src/e2e-harness/schemas/index.ts +220 -0
  356. package/src/e2e-harness/schemas.test.ts +145 -0
  357. package/src/e2e-harness/stack.test.ts +124 -0
  358. package/src/e2e-harness/stack.ts +306 -0
  359. package/src/e2e-harness/steps.ts +30 -0
  360. package/src/e2e-harness.ts +2 -0
  361. package/src/exit-codes.test.ts +3 -2
  362. package/src/exit-codes.ts +7 -1
  363. package/src/gate-decision-bundle.test.ts +0 -2
  364. package/src/lexicon.ts +57 -0
  365. package/src/lifecycle/control-entries-ledger.test.ts +2 -3
  366. package/src/lifecycle/gate-ledger.ts +2 -3
  367. package/src/lifecycle/gated-request.ts +1 -2
  368. package/src/lifecycle/git.test.ts +155 -0
  369. package/src/lifecycle/git.ts +213 -17
  370. package/src/lifecycle/lock-rows.test.ts +6 -1
  371. package/src/lifecycle/lock-rows.ts +58 -7
  372. package/src/lifecycle/query.ts +4 -5
  373. package/src/lifecycle/release-catalog.test.ts +3 -4
  374. package/src/lifecycle/release-catalog.ts +1 -1
  375. package/src/lifecycle/release-ledger.ts +1 -2
  376. package/src/lifecycle/release-status.test.ts +3 -4
  377. package/src/lifecycle/release-status.ts +1 -2
  378. package/src/lifecycle/resource-lock-wait.test.ts +292 -0
  379. package/src/lifecycle/resource-lock.ts +261 -7
  380. package/src/lifecycle/wave-plans.ts +33 -5
  381. package/src/op/approval-status.test.ts +134 -0
  382. package/src/op/approval-status.ts +235 -0
  383. package/src/op/gate-review.test.ts +2 -1
  384. package/src/op/gate.test.ts +7 -5
  385. package/src/op/gate.ts +20 -4
  386. package/src/op/index.ts +2 -0
  387. package/src/op/op-waves-after-plan.test.ts +11 -0
  388. package/src/op/op-waves-capability-spec.ts +20 -0
  389. package/src/op/op-waves-ledger-lock.test.ts +208 -0
  390. package/src/op/op-waves-parallelism.test.ts +89 -0
  391. package/src/op/op-waves-pull-request.test.ts +78 -1
  392. package/src/op/op-waves-release-port.ts +1 -1
  393. package/src/op/op-waves-release.ts +2 -3
  394. package/src/op/op-waves-run.ts +196 -31
  395. package/src/op/op-waves-stand-down.ts +1 -2
  396. package/src/op/op-waves.ts +81 -6
  397. package/src/op/runtime.ts +6 -3
  398. package/src/otlp.ts +1 -2
  399. package/src/parallelism.test.ts +38 -0
  400. package/src/parallelism.ts +33 -0
  401. package/src/policy-source.ts +1 -2
  402. package/src/pr-forge-bundle.test.ts +1 -1
  403. package/src/pr-forge.ts +54 -35
  404. package/src/pr-loop-bundle.test.ts +0 -2
  405. package/src/pr-loop-narrowed.test.ts +63 -0
  406. package/src/pr-loop.ts +30 -4
  407. package/src/pr-merge.test.ts +100 -0
  408. package/src/pr-merge.ts +105 -0
  409. package/src/pr-post-stale.test.ts +163 -0
  410. package/src/pr-post.ts +159 -5
  411. package/src/pr-report-url.ts +1 -2
  412. package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
  413. package/src/release-floors.ts +1 -1
  414. package/src/run-event.ts +1 -2
  415. package/src/scheduled-op-cloud.ts +68 -0
  416. package/src/stage-hooks-bundle.test.ts +0 -2
  417. package/src/workspace/ci-lock-grain.ts +1 -2
  418. package/src/workspace/ci-run.ts +5 -1
  419. package/src/workspace/pr-report.schema.json +5 -0
@@ -24,6 +24,19 @@
24
24
  * for one release), or, for a run on this host outside CI, when its
25
25
  * process is. Anything nobody can answer counts as alive.
26
26
  * - A release never throws: a row left held is taken over once its run is gone.
27
+ * - A take may wait (ruling for ci-products 2026-10-28, "Ledger lock"): the
28
+ * `target` and `repo` grains, a stock Pulumi stack's `stack` row, a
29
+ * Terraform root's `root` row or the `repo` row. A waiting run adds itself
30
+ * to `waiting` in the file, and takes its rows only once no live run holds
31
+ * any of them and no live waiter for a row that meets one of them comes
32
+ * first. First is the older commit (`commitAt`, the commit time of the
33
+ * commit the run applies), then the lower run id (both numbers, else by
34
+ * text), then the commit sha: the run that started first among runs of one
35
+ * commit. A waiter that is gone is dropped by the next writer, as a holder
36
+ * is. A wait that reaches its deadline (`CHANT_LOCK_WAIT` seconds, which
37
+ * the waves pipelines set from the job's timeout) leaves the queue and
38
+ * fails with {@link LockWaitTimeoutError}, the table's `held`, exit 5. A
39
+ * take on the resource grain never waits: a held row refuses it at once.
27
40
  *
28
41
  * The writes go through chant's ledger code (./git.ts) with the same
29
42
  * read-then-CAS and push the target locks use, in place of terragucci's raw
@@ -35,6 +48,7 @@
35
48
  * exit 5, and names the run that holds it.
36
49
  */
37
50
  import { hostname } from "node:os";
51
+ import { getRuntime } from "../runtime-adapter.js";
38
52
  import { pushLifecycleStatus, readBlobBySha, readPathSha, RefCASConflictError, writeBlobToPath } from "./git.js";
39
53
  import { lockRowsConflict, sortedLockRows } from "./lock-rows.js";
40
54
  import { dropRefusedWrite, fetchForLocks, localTip, LOCKS_DIR, targetLockGateProblem } from "./target-lock.js";
@@ -135,7 +149,26 @@ export function parseLockRows(text) {
135
149
  for (const [k, id] of Object.entries(doc.rows))
136
150
  if (typeof id === "string" && holders[id])
137
151
  rows[k] = id;
138
- return { version: 1, holders, rows };
152
+ const waiting = {};
153
+ const rawWaiting = doc.waiting;
154
+ if (rawWaiting && typeof rawWaiting === "object") {
155
+ for (const [id, raw] of Object.entries(rawWaiting)) {
156
+ if (typeof raw?.run !== "string" || typeof raw.at !== "string" || !Array.isArray(raw.keys))
157
+ continue;
158
+ const keys = raw.keys.filter((k) => typeof k === "string");
159
+ if (keys.length === 0)
160
+ continue;
161
+ waiting[id] = {
162
+ run: raw.run,
163
+ at: raw.at,
164
+ keys,
165
+ ...(typeof raw.url === "string" ? { url: raw.url } : {}),
166
+ ...(typeof raw.sha === "string" ? { sha: raw.sha } : {}),
167
+ ...(typeof raw.commitAt === "string" ? { commitAt: raw.commitAt } : {}),
168
+ };
169
+ }
170
+ }
171
+ return { version: 1, holders, rows, ...(Object.keys(waiting).length > 0 ? { waiting } : {}) };
139
172
  }
140
173
  }
141
174
  catch {
@@ -146,7 +179,8 @@ export function parseLockRows(text) {
146
179
  /** The file's text, keys sorted, so two writes of the same rows are the same blob. */
147
180
  export function renderLockRows(file) {
148
181
  const sort = (r) => Object.fromEntries(Object.keys(r).sort().map((k) => [k, r[k]]));
149
- return `${JSON.stringify({ version: 1, holders: sort(file.holders), rows: sort(file.rows) }, null, 2)}\n`;
182
+ const waiting = file.waiting && Object.keys(file.waiting).length > 0 ? { waiting: sort(file.waiting) } : {};
183
+ return `${JSON.stringify({ version: 1, holders: sort(file.holders), rows: sort(file.rows), ...waiting }, null, 2)}\n`;
150
184
  }
151
185
  /** Who else holds a row that meets any of `keys`, split into runs still going and runs that are gone. */
152
186
  export async function heldLockRowsIn(file, keys, me, alive) {
@@ -173,21 +207,69 @@ export async function heldLockRowsIn(file, keys, me, alive) {
173
207
  * `gone`. Pure, so the decision can be checked without git.
174
208
  */
175
209
  export function withRowsTaken(file, keys, me, gone) {
176
- const next = { version: 1, holders: { ...file.holders }, rows: { ...file.rows } };
210
+ const next = copyRows(file);
177
211
  for (const id of gone) {
178
212
  delete next.holders[id];
179
213
  for (const [k, h] of Object.entries(next.rows))
180
214
  if (h === id)
181
215
  delete next.rows[k];
216
+ delete next.waiting?.[id];
182
217
  }
183
- next.holders[me.run] = me;
218
+ delete next.waiting?.[me.run];
219
+ next.holders[me.run] = { run: me.run, at: me.at, ...(me.url ? { url: me.url } : {}), ...(me.sha ? { sha: me.sha } : {}) };
184
220
  for (const k of keys)
185
221
  next.rows[k] = me.run;
222
+ return tidyWaiting(next);
223
+ }
224
+ function copyRows(file) {
225
+ return { version: 1, holders: { ...file.holders }, rows: { ...file.rows }, ...(file.waiting ? { waiting: { ...file.waiting } } : {}) };
226
+ }
227
+ function tidyWaiting(file) {
228
+ if (file.waiting && Object.keys(file.waiting).length === 0)
229
+ delete file.waiting;
230
+ return file;
231
+ }
232
+ /** The rows file with `me` in the queue for `keys`, less the waiters in `gone`. Pure. */
233
+ export function withWaiter(file, me, gone = []) {
234
+ const next = copyRows(file);
235
+ next.waiting = { ...(next.waiting ?? {}) };
236
+ for (const id of gone)
237
+ delete next.waiting[id];
238
+ next.waiting[me.run] = { ...me, keys: [...new Set(me.keys)].sort() };
186
239
  return next;
187
240
  }
241
+ /** The rows file with `me` out of the queue. Pure. */
242
+ export function withoutWaiter(file, me) {
243
+ const next = copyRows(file);
244
+ delete next.waiting?.[me];
245
+ return tidyWaiting(next);
246
+ }
247
+ /**
248
+ * Whether waiter `a` goes before waiter `b`: the older commit first, then the
249
+ * lower run id (as numbers when both are, else as text), then the commit
250
+ * sha. A waiter with no commit time goes after every one that has one.
251
+ */
252
+ export function waiterBefore(a, b) {
253
+ const time = (w) => {
254
+ const t = w.commitAt ? new Date(w.commitAt).getTime() : NaN;
255
+ return Number.isFinite(t) ? t : Number.POSITIVE_INFINITY;
256
+ };
257
+ const ta = time(a);
258
+ const tb = time(b);
259
+ if (ta !== tb)
260
+ return ta < tb;
261
+ if (a.run !== b.run) {
262
+ const na = Number(a.run);
263
+ const nb = Number(b.run);
264
+ if (/^\d+$/.test(a.run) && /^\d+$/.test(b.run) && na !== nb)
265
+ return na < nb;
266
+ return a.run < b.run;
267
+ }
268
+ return (a.sha ?? "") < (b.sha ?? "");
269
+ }
188
270
  /** The rows file after `me` lets go of `keys`; its holder entry goes once it holds no row. */
189
271
  export function withRowsReleased(file, keys, me) {
190
- const next = { version: 1, holders: { ...file.holders }, rows: { ...file.rows } };
272
+ const next = copyRows(file);
191
273
  for (const k of keys)
192
274
  if (next.rows[k] === me)
193
275
  delete next.rows[k];
@@ -264,6 +346,149 @@ export async function takeLockRows(gate, rows, me, opts = {}) {
264
346
  }
265
347
  throw new Error(`could not hold the rows of ${gate}: ${STATE_BRANCH} kept moving; check that the job may push to it`);
266
348
  }
349
+ /** A wait for rows reached its deadline (ruling for ci-products 2026-10-28): nothing applied. Exit 5, as a held row is. */
350
+ export class LockWaitTimeoutError extends Error {
351
+ constructor(message, held, ahead, waitedSeconds) {
352
+ super(message);
353
+ this.held = held;
354
+ this.ahead = ahead;
355
+ this.waitedSeconds = waitedSeconds;
356
+ this.lockRowsHeld = true;
357
+ this.name = "LockWaitTimeoutError";
358
+ }
359
+ }
360
+ /** The default wait when a job names no timeout: just under three hours, a Forgejo runner's default job timeout. */
361
+ export const DEFAULT_LOCK_WAIT_SECONDS = 3 * 3600 - 300;
362
+ /** How long a take waits, in seconds: `CHANT_LOCK_WAIT`, else {@link DEFAULT_LOCK_WAIT_SECONDS}. */
363
+ export function lockWaitSeconds(env) {
364
+ const n = Number(env.CHANT_LOCK_WAIT);
365
+ return env.CHANT_LOCK_WAIT !== undefined && Number.isFinite(n) && n >= 0 ? n : DEFAULT_LOCK_WAIT_SECONDS;
366
+ }
367
+ /** The poll interval in ms: `CHANT_LOCK_POLL` seconds, else 10 s. */
368
+ export function lockPollMs(env) {
369
+ const n = Number(env.CHANT_LOCK_POLL);
370
+ return env.CHANT_LOCK_POLL !== undefined && Number.isFinite(n) && n > 0 ? n * 1000 : 10000;
371
+ }
372
+ /** The commit time of `rev` in `cwd` (ISO 8601), or undefined when git cannot say. */
373
+ export async function commitTimeOf(rev, cwd) {
374
+ const out = await getRuntime().spawn(["git", "show", "-s", "--format=%cI", rev], { cwd });
375
+ const t = out.exitCode === 0 ? out.stdout.trim() : "";
376
+ return t && Number.isFinite(new Date(t).getTime()) ? t : undefined;
377
+ }
378
+ /** The live waiters for a row that meets one of `keys` who go before `me`, and the waiters that are gone. */
379
+ export async function waitersAhead(file, keys, me, alive) {
380
+ const ahead = [];
381
+ const gone = [];
382
+ for (const [id, w] of Object.entries(file.waiting ?? {})) {
383
+ if (id === me.run || w.run === me.run)
384
+ continue;
385
+ if (!w.keys.some((k) => keys.some((mine) => lockRowsConflict(k, mine))))
386
+ continue;
387
+ const verdict = await alive(w);
388
+ if (verdict === "dead") {
389
+ gone.push(id);
390
+ continue;
391
+ }
392
+ if (waiterBefore(w, me))
393
+ ahead.push(w);
394
+ }
395
+ return { ahead: ahead.sort((a, b) => (waiterBefore(a, b) ? -1 : 1)), gone: gone.sort() };
396
+ }
397
+ function describeWait(held, ahead, rows) {
398
+ const parts = [];
399
+ if (held.length > 0)
400
+ parts.push(describeHeldLockRows(held, rows));
401
+ if (ahead.length > 0)
402
+ parts.push(`${ahead.map((w) => `run ${w.run}${w.url ? ` (${w.url})` : ""}`).join(", ")} ${ahead.length === 1 ? "waits" : "wait"} ahead of it with an older commit`);
403
+ return parts.join("; ");
404
+ }
405
+ /**
406
+ * Take `rows` for `me`, waiting in the queue until no live run holds any of
407
+ * them and no live waiter that goes first ({@link waiterBefore}) waits for a
408
+ * row that meets one of them. Throws {@link LockWaitTimeoutError} at the
409
+ * deadline, after leaving the queue.
410
+ */
411
+ export async function waitLockRows(gate, rows, me, wait, opts = {}) {
412
+ checkGate(gate);
413
+ const keys = sortedLockRows(rows).map((r) => r.key);
414
+ if (keys.length === 0)
415
+ return { ok: true, tookOver: [], pushed: false, waitedSeconds: 0, waited: false };
416
+ const alive = opts.alive ?? forgeLockLiveness(process.env);
417
+ const now = wait.now ?? Date.now;
418
+ const sleep = wait.sleep ?? pause;
419
+ const poll = wait.pollMs ?? lockPollMs(process.env);
420
+ const stale = lockStaleSeconds(process.env) * 1000;
421
+ const started = now();
422
+ const waiter = () => ({ ...me, keys, ...(wait.commitAt ? { commitAt: wait.commitAt } : {}) });
423
+ let queued;
424
+ let said = "";
425
+ await fetchForLocks(opts.cwd);
426
+ for (let raced = 0;;) {
427
+ const { sha, file } = await readCurrent(gate, opts.cwd);
428
+ const mine = queued ?? waiter();
429
+ const { live, gone } = await heldLockRowsIn(file, keys, me.run, alive);
430
+ const { ahead, gone: goneWaiters } = await waitersAhead(file, keys, mine, alive);
431
+ if (live.length === 0 && ahead.length === 0) {
432
+ const next = withRowsTaken(file, keys, me, gone);
433
+ for (const id of goneWaiters)
434
+ delete next.waiting?.[id];
435
+ const took = gone.length ? `, taken over from run ${gone.join(", ")}` : "";
436
+ const wrote = await writeAndPush(gate, sha, tidyWaiting(next), `Hold ${keys.length} row${keys.length === 1 ? "" : "s"} of ${gate} for run ${me.run}${took}`, opts.cwd);
437
+ if (wrote)
438
+ return { ok: true, tookOver: gone.map((id) => file.holders[id]), pushed: wrote.pushed, waitedSeconds: Math.round((now() - started) / 1000), waited: queued !== undefined };
439
+ if (++raced >= ATTEMPTS)
440
+ throw new Error(`could not hold the rows of ${gate}: ${STATE_BRANCH} kept moving; check that the job may push to it`);
441
+ await sleep(200 + Math.floor(Math.random() * 800));
442
+ continue;
443
+ }
444
+ const why = describeWait(live, ahead, rows);
445
+ if (now() >= wait.deadline) {
446
+ await leaveQueue(gate, me.run, opts.cwd);
447
+ const waited = Math.round((now() - started) / 1000);
448
+ throw new LockWaitTimeoutError(`waited ${waited}s for ${keys.join(", ")} of ${gate} and gave up at the job's deadline: ${why}`, live, ahead, waited);
449
+ }
450
+ const inFile = file.waiting?.[me.run];
451
+ const refresh = inFile ? now() - new Date(inFile.at).getTime() > stale / 2 : true;
452
+ if (!inFile || refresh || goneWaiters.length > 0) {
453
+ const entry = { ...waiter(), at: new Date(now()).toISOString() };
454
+ const wrote = await writeAndPush(gate, sha, withWaiter(file, entry, goneWaiters), `Run ${me.run} waits for ${keys.length} row${keys.length === 1 ? "" : "s"} of ${gate}`, opts.cwd);
455
+ if (!wrote) {
456
+ if (++raced >= ATTEMPTS)
457
+ throw new Error(`could not join the queue for the rows of ${gate}: ${STATE_BRANCH} kept moving; check that the job may push to it`);
458
+ await sleep(200 + Math.floor(Math.random() * 800));
459
+ continue;
460
+ }
461
+ queued = entry;
462
+ }
463
+ else {
464
+ queued ?? (queued = inFile);
465
+ }
466
+ raced = 0;
467
+ if (why !== said) {
468
+ wait.log?.(`waits for ${keys.join(", ")} of ${gate}: ${why}`);
469
+ said = why;
470
+ }
471
+ await sleep(Math.max(0, Math.min(poll, wait.deadline - now())));
472
+ await fetchForLocks(opts.cwd);
473
+ }
474
+ }
475
+ /** Take run `me` out of `gate`'s queue. Never throws. */
476
+ async function leaveQueue(gate, me, cwd) {
477
+ try {
478
+ await fetchForLocks(cwd);
479
+ for (let attempt = 0; attempt < ATTEMPTS; attempt++) {
480
+ const { sha, file } = await readCurrent(gate, cwd);
481
+ if (!file.waiting?.[me])
482
+ return;
483
+ if (await writeAndPush(gate, sha, withoutWaiter(file, me), `Run ${me} stops waiting for rows of ${gate}`, cwd))
484
+ return;
485
+ await pause(200 + Math.floor(Math.random() * 800));
486
+ }
487
+ }
488
+ catch {
489
+ // A waiter left behind is dropped once its run is gone.
490
+ }
491
+ }
267
492
  /** Let go of `keys` where run `me` still holds them. Never throws: a row left held is taken over once the run is gone. */
268
493
  export async function releaseLockRows(gate, keys, me, opts = {}) {
269
494
  try {
@@ -310,6 +535,17 @@ export async function leaseLockRows(gate, rows, opts = {}) {
310
535
  const lease = { gate, holder, keys, release: () => (keys.length === 0 ? Promise.resolve(true) : releaseLockRows(gate, keys, holder.run, { ...(opts.cwd ? { cwd: opts.cwd } : {}) })) };
311
536
  if (keys.length === 0)
312
537
  return { ok: true, lease, tookOver: [] };
538
+ if (opts.wait) {
539
+ try {
540
+ const waited = await waitLockRows(gate, rows, holder, opts.wait, opts);
541
+ return { ok: true, lease, tookOver: waited.tookOver, ...(waited.waited ? { waited: true, waitedSeconds: waited.waitedSeconds } : {}) };
542
+ }
543
+ catch (err) {
544
+ if (err instanceof LockWaitTimeoutError)
545
+ return { ok: false, held: err.held, message: err.message, timedOut: true };
546
+ throw err;
547
+ }
548
+ }
313
549
  const taken = await takeLockRows(gate, rows, holder, opts);
314
550
  if (!taken.ok)
315
551
  return { ok: false, held: taken.held, message: describeHeldLockRows(taken.held, rows) };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The plans an op-waves `pr-review` wave records for a pull request's head
3
- * (#3684, #3865): `_wave-plans/<name>/<head>.json` on `chant/lifecycle`,
2
+ * The plans an op-waves `pr-review` or `pull-request` wave records for a
3
+ * pull request's head (#3684, #3865, #4630): `_wave-plans/<name>/<head>.json` on `chant/lifecycle`,
4
4
  * written by `chant run wave --record-plans` (`../op/op-waves-run.ts`) and read
5
5
  * after the merge, where the review of that head approves the digests it
6
6
  * planned and only those (`../op/gate-review.ts`).
@@ -21,11 +21,27 @@ export interface HeadPlans {
21
21
  /** The commit the waves were planned at: a pull request's head. */
22
22
  head: string;
23
23
  timestamp: string;
24
- waves: Array<{
25
- wave: number;
26
- name: string;
27
- digest: string;
28
- }>;
24
+ waves: Array<HeadPlanWave>;
25
+ }
26
+ /**
27
+ * One wave's plan at the head. `changes` and `destructive` (#4630) are the
28
+ * plan's facts a gate policy reads: some run changes something, some run's
29
+ * plan is destructive. A record from an older chant has neither, and a
30
+ * reader takes such a wave as changing.
31
+ */
32
+ export interface HeadPlanWave {
33
+ wave: number;
34
+ name: string;
35
+ digest: string;
36
+ changes?: boolean;
37
+ destructive?: boolean;
38
+ /**
39
+ * The digest of the wave's change set at the head, when its plans file
40
+ * gave one (#4630, `pull-request` waves). The document is stored under
41
+ * `_change-sets/`, and the approval status checks the pull request's own
42
+ * approval against it.
43
+ */
44
+ changeSet?: string;
29
45
  }
30
46
  /** Where {@link HeadPlans} for `head` live on `chant/lifecycle`: `_wave-plans/<name>/<head>.json`. */
31
47
  export declare const HEAD_PLANS_DIR = "_wave-plans";
@@ -1 +1 @@
1
- {"version":3,"file":"wave-plans.d.ts","sourceRoot":"","sources":["../../src/lifecycle/wave-plans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,2FAA2F;AAC3F,MAAM,WAAW,SAAS;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E,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAS1G;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEjE;AAED,gGAAgG;AAChG,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAIvH;AAED,sFAAsF;AACtF,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE/E"}
@@ -26,10 +26,17 @@ export function parseHeadPlans(text) {
26
26
  for (const w of r.waves) {
27
27
  if (w === null || typeof w !== "object")
28
28
  return null;
29
- const { wave, name, digest } = w;
29
+ const { wave, name, digest, changes, destructive, changeSet } = w;
30
30
  if (typeof wave !== "number" || typeof name !== "string" || typeof digest !== "string")
31
31
  return null;
32
- waves.push({ wave, name, digest });
32
+ waves.push({
33
+ wave,
34
+ name,
35
+ digest,
36
+ ...(typeof changes === "boolean" ? { changes } : {}),
37
+ ...(typeof destructive === "boolean" ? { destructive } : {}),
38
+ ...(typeof changeSet === "string" && changeSet !== "" ? { changeSet } : {}),
39
+ });
33
40
  }
34
41
  return { version: 1, name: r.name, head: r.head, timestamp: r.timestamp, waves };
35
42
  }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The approval status before merge (#4630): `<product>/approval` on an open
3
+ * pull request's head says whether the waves its merge will run wait for an
4
+ * approval. It covers the waves whose approval at base is `pr-review` and,
5
+ * under the 2026-10-28 ruling, the waves whose approval is `pull-request`.
6
+ *
7
+ * - `pending` while a wave whose gate the plan will hold has no approval
8
+ * that would pass it: under `pr-review` an approving review of that head,
9
+ * by a writer other than its author; under `pull-request` the pull
10
+ * request's own approval (below).
11
+ * - `success` once every such wave has one, or when no wave's gate holds
12
+ * the plan.
13
+ *
14
+ * Which waves the gate holds is read the way the wave job reads it after the
15
+ * merge: each wave's approval mode and policy from the spec at the pull
16
+ * request's base (`readOpWavePolicy`), applied to the facts the head's plans
17
+ * record (`chant run wave --record-plans`, `../lifecycle/wave-plans.ts`):
18
+ * whether a run changes anything and whether a plan is destructive. A head
19
+ * whose plans are not recorded yet is pending, since nothing says its waves
20
+ * pass.
21
+ *
22
+ * The pull request's own approval, for a `pull-request` wave: an approval at
23
+ * the pull request's gate (`approvals.pullRequest.gate` at base) whose
24
+ * change set covers the wave's change set at the head, as the merged wave
25
+ * checks it (`planCoveredBy`). The approval is read on the pull request's
26
+ * op (`pr-<n>`), where the product's approve line records it, and on the
27
+ * spec's op, which the merged wave reads. The head's change set is the one
28
+ * `--record-plans` stored for the wave; a record without one is pending.
29
+ *
30
+ * The status job reads only: the pull request, its reviews and
31
+ * `chant/lifecycle`. It writes the one commit status. On GitHub and Forgejo
32
+ * it runs after the record-plans job and on every review; on GitLab, whose
33
+ * approvals start no pipeline, a scheduled pipeline of the target branch
34
+ * posts it for every open merge request (`--open`). An approval recorded on
35
+ * the ledger starts no run on any forge: the next push, review or `--open`
36
+ * run posts it. The status advises: the gate after the merge decides, from
37
+ * the ledger and the merged review.
38
+ */
39
+ import { type CiProductWords } from "../ci-product-words.js";
40
+ import type { ChangeSetDocument } from "../change-set.js";
41
+ import type { GateResolutionRecord } from "../lifecycle/gate-ledger.js";
42
+ import type { HeadPlans } from "../lifecycle/wave-plans.js";
43
+ import type { PrApproverFilter, PrForge } from "../pr-forge.js";
44
+ import type { OpWaveGatePolicy, OpWavesSpec } from "./op-waves.js";
45
+ import type { OpWaveShowAtBase } from "./op-waves-run.js";
46
+ /** What the status says. */
47
+ export interface ApprovalStatus {
48
+ state: "pending" | "success";
49
+ description: string;
50
+ /** The waves whose gate the plan will hold, by number. */
51
+ waits: number[];
52
+ /** Who approved the head, when someone did. */
53
+ approvers: string[];
54
+ }
55
+ export interface ApprovalStatusInput {
56
+ spec: OpWavesSpec;
57
+ /** The spec's path, which the policy is read from at `base`. */
58
+ specFile: string;
59
+ forge: Pick<PrForge, "prApproved" | "kind">;
60
+ pr: number;
61
+ /** The pull request's head commit. */
62
+ head: string;
63
+ /** The pull request's base commit, which the policy is read at. */
64
+ base: string;
65
+ cwd?: string;
66
+ /** The head's recorded plans. Default: `chant/lifecycle` at `cwd`. */
67
+ readPlans?: (name: string, head: string) => Promise<HeadPlans | null>;
68
+ /** How the spec is read at base. Default `git show`. */
69
+ show?: OpWaveShowAtBase;
70
+ /** Who may approve, as the forge's requires check takes it. */
71
+ approvers?: PrApproverFilter;
72
+ /** The resolutions on one op's gate ledger, for a `pull-request` wave. Default: `chant/lifecycle` at `cwd`. */
73
+ readResolutions?: (op: string) => Promise<GateResolutionRecord[]>;
74
+ /** A stored change set by digest, for a `pull-request` wave. Default: `_change-sets/` on `chant/lifecycle` at `cwd`. */
75
+ changeSets?: (digest: string) => Promise<ChangeSetDocument | undefined>;
76
+ }
77
+ /** Whether `policy` holds a wave with these facts. A record with no facts reads as changing, so it holds under `always`. */
78
+ export declare function headWaveHolds(policy: OpWaveGatePolicy, facts: {
79
+ changes?: boolean;
80
+ destructive?: boolean;
81
+ }): boolean;
82
+ /** The status for one pull request's head. Throws only when the spec cannot be read at base. */
83
+ export declare function approvalStatusOf(input: ApprovalStatusInput): Promise<ApprovalStatus>;
84
+ /** Post the status on the head. Returns what was posted. */
85
+ export declare function postApprovalStatus(input: ApprovalStatusInput & {
86
+ forge: Pick<PrForge, "prApproved" | "kind" | "setStatus" | "runUrl">;
87
+ }, words?: CiProductWords): Promise<ApprovalStatus>;
88
+ /**
89
+ * Post the status on every open pull request into `branch` (#4630), for
90
+ * GitLab's scheduled pipeline: the forge names each head and base. One
91
+ * that fails is a warning, and the rest are posted.
92
+ */
93
+ export declare function postOpenApprovalStatuses(input: Omit<ApprovalStatusInput, "pr" | "head" | "base"> & {
94
+ forge: Pick<PrForge, "prApproved" | "kind" | "setStatus" | "runUrl" | "openPullRequests">;
95
+ branch: string;
96
+ }, words?: CiProductWords): Promise<{
97
+ posted: Array<{
98
+ pr: number;
99
+ status: ApprovalStatus;
100
+ }>;
101
+ warnings: string[];
102
+ }>;
103
+ //# sourceMappingURL=approval-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-status.d.ts","sourceRoot":"","sources":["../../src/op/approval-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAA4C,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC;IAC5C,EAAE,EAAE,MAAM,CAAC;I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