@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
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Runs a wave applies at once (#4625): `parallelism` on the spec or a wave,
3
+ * with a capability step, at most that many applies in flight, a run
4
+ * waiting for an earlier run it depends on and blocked when that failed.
5
+ * Written for the ci-products post-merge pass.
6
+ */
7
+
8
+ import { describe, expect, test } from "vitest";
9
+ import { mkdtempSync, rmSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { tmpdir } from "node:os";
12
+ import { assertOpWavesSpec, type OpWavesSpec } from "./op-waves";
13
+ import { runOpWave, type OpWaveShowAtBase } from "./op-waves-run";
14
+ import { memoryGateLedgerPort } from "./gate";
15
+ import { CapabilityRegistry, type Capability } from "../components/capability";
16
+
17
+ const digest = (n: string) => `sha256:${n.repeat(64)}`;
18
+
19
+ function capability(opts: { fail?: string[]; delayMs?: number } = {}) {
20
+ const seen = { running: 0, most: 0, order: [] as string[] };
21
+ const cap: Capability<Record<string, unknown>, unknown> = {
22
+ kind: "fake-apply",
23
+ async plan(_ctx, input) {
24
+ const root = String(input.root);
25
+ return { member: root, planDigest: digest("1"), artifact: {}, changeSet: { member: { member: root, lexicon: "terraform", planner: "chant", status: "planned", planDigest: digest("1"), holes: [] }, entries: [] } };
26
+ },
27
+ async run(_ctx, input) {
28
+ const root = String(input.root);
29
+ seen.running++;
30
+ seen.most = Math.max(seen.most, seen.running);
31
+ await new Promise((r) => setTimeout(r, opts.delayMs ?? 5));
32
+ seen.running--;
33
+ seen.order.push(root);
34
+ if (opts.fail?.includes(root)) throw new Error(`${root} broke`);
35
+ return { applied: root };
36
+ },
37
+ };
38
+ return { registry: new CapabilityRegistry().register(cap), seen };
39
+ }
40
+
41
+ const spec = (parallelism: number, runs: OpWavesSpec["waves"][number]["runs"]): OpWavesSpec => ({
42
+ name: "roots",
43
+ op: "tf-apply",
44
+ parallelism,
45
+ step: { kind: "fake-apply", root: "{target}" },
46
+ waves: [{ name: "dev", runs, gate: "never" }],
47
+ });
48
+
49
+ async function run(s: OpWavesSpec, registry: CapabilityRegistry) {
50
+ const cwd = mkdtempSync(join(tmpdir(), "op-waves-par-"));
51
+ const show: OpWaveShowAtBase = () => ({ sha: "b".repeat(40), text: JSON.stringify(s) });
52
+ try {
53
+ return await runOpWave({ spec: s, specFile: "waves.json", wave: 1, cwd, show, gates: memoryGateLedgerPort(), capabilities: registry });
54
+ } finally {
55
+ rmSync(cwd, { recursive: true, force: true });
56
+ }
57
+ }
58
+
59
+ describe("runs applied at once (#4625)", () => {
60
+ test("at most parallelism applies in flight, and the result keeps the wave's order", async () => {
61
+ const { registry, seen } = capability();
62
+ const result = await run(spec(2, [{ target: "a" }, { target: "b" }, { target: "c" }, { target: "d" }]), registry);
63
+ expect(result).toMatchObject({ exitCode: 0, applied: ["a", "b", "c", "d"] });
64
+ expect(seen.most).toBe(2);
65
+ });
66
+
67
+ test("a run waits for an earlier run it depends on, and is blocked when that one failed", async () => {
68
+ const { registry, seen } = capability({ fail: ["a"] });
69
+ const result = await run(spec(3, [{ target: "a" }, { target: "b", dependsOn: ["a"] }, { target: "c" }, { target: "d", dependsOn: ["b"] }]), registry);
70
+ expect(result.exitCode).toBe(1);
71
+ expect(result.failed).toEqual(["a"]);
72
+ expect(result.applied).toEqual(["c"]);
73
+ expect(result.blocked).toEqual({ b: "a", d: "a" });
74
+ expect(seen.order).not.toContain("b");
75
+ });
76
+
77
+ test("one at a time when the spec says nothing", async () => {
78
+ const { registry, seen } = capability();
79
+ const { parallelism: _p, ...plain } = spec(1, [{ target: "a" }, { target: "b" }]);
80
+ await run(plain, registry);
81
+ expect(seen.most).toBe(1);
82
+ });
83
+
84
+ test("the spec refuses a parallelism over 1 without a step, and one that is not a whole number", () => {
85
+ const { step: _s, ...noStep } = spec(2, [{ target: "a" }]);
86
+ expect(() => assertOpWavesSpec({ ...noStep, apply: ["./apply", "{target}"], plan: ["./plan", "{target}", "{plan}"] })).toThrow(/apply at once only through `step`/);
87
+ expect(() => assertOpWavesSpec(spec(0, [{ target: "a" }]))).toThrow(/whole number of 1 or more/);
88
+ });
89
+ });
@@ -3,7 +3,9 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { tmpdir } from "node:os";
5
5
  import { assertOpWavesSpec, type OpWavesSpec } from "./op-waves";
6
- import { runOpWave, type OpWaveExec, type OpWaveShowAtBase } from "./op-waves-run";
6
+ import { recordOpWaveHeadPlans, runOpWave, type OpWaveExec, type OpWaveShowAtBase } from "./op-waves-run";
7
+ import { approvalStatusOf } from "./approval-status";
8
+ import type { HeadPlans } from "../lifecycle/wave-plans";
7
9
  import { memoryGateLedgerPort, type GateLedgerPort } from "./gate";
8
10
  import { composeChangeSet, type ChangeSetDocument, type ChangeSetMember } from "../change-set";
9
11
  import type { GateResolutionRecord } from "../lifecycle/gate-ledger";
@@ -140,3 +142,78 @@ describe("planWave and applyWave run by the caller (#4588)", () => {
140
142
  }
141
143
  });
142
144
  });
145
+
146
+ describe("the approval status of a pull-request wave before merge (#4630, 2026-10-28 ruling)", () => {
147
+ const HEAD = "c".repeat(40);
148
+ const forge = { kind: "github" as const, async prApproved() { throw new Error("a pull-request wave reads no review"); } };
149
+
150
+ async function recorded(waveDoc: ChangeSetDocument): Promise<{ plans: HeadPlans; stored: ChangeSetDocument[] }> {
151
+ const h = harness(waveDoc);
152
+ const stored: ChangeSetDocument[] = [];
153
+ try {
154
+ const plans = await recordOpWaveHeadPlans({ spec, cwd: h.cwd, exec: h.exec, head: HEAD, now: "t", write: async () => {}, storeChangeSet: async (d) => void stored.push(d) });
155
+ return { plans, stored };
156
+ } finally {
157
+ h.done();
158
+ }
159
+ }
160
+
161
+ const statusOf = (plans: HeadPlans, stored: ChangeSetDocument[], resolutions: Record<string, GateResolutionRecord[]>) =>
162
+ approvalStatusOf({
163
+ spec,
164
+ specFile: ".chant/op-waves/pulumi-up.spec.json",
165
+ forge,
166
+ pr: 7,
167
+ head: HEAD,
168
+ base: "b".repeat(40),
169
+ show: () => ({ sha: "b".repeat(40), text: JSON.stringify(spec) }),
170
+ readPlans: async () => plans,
171
+ readResolutions: async (op) => resolutions[op] ?? [],
172
+ changeSets: async (d) => stored.find((x) => x.digest === d),
173
+ });
174
+
175
+ test("--record-plans keeps the wave's change set and stores it", async () => {
176
+ const waveDoc = doc(digest("a"));
177
+ const { plans, stored } = await recorded(waveDoc);
178
+ expect(plans.waves[0]).toMatchObject({ wave: 1, changeSet: waveDoc.digest });
179
+ expect(stored.map((d) => d.digest)).toEqual([waveDoc.digest]);
180
+ });
181
+
182
+ test("pending with no approval at the pull request's gate, success once the pull request's approval covers the wave", async () => {
183
+ const approved = doc(digest("a"));
184
+ const { plans, stored } = await recorded(approved);
185
+ expect(await statusOf(plans, stored, {})).toMatchObject({ state: "pending", waits: [1], description: expect.stringContaining("gate up has no approval") });
186
+ // The product's approve line records on the pull request's op.
187
+ const onPr = { ...approval(approved), op: "pr-7" } as GateResolutionRecord;
188
+ expect(await statusOf(plans, stored, { "pr-7": [onPr] })).toMatchObject({ state: "success", waits: [1], approvers: ["github:alice"] });
189
+ // The spec's op, which the merged wave reads, counts as well.
190
+ expect(await statusOf(plans, stored, { "pulumi-up": [approval(approved)] })).toMatchObject({ state: "success" });
191
+ });
192
+
193
+ test("an approval of another plan does not cover the head's, and a record with no change set is pending", async () => {
194
+ const other = doc(digest("d"));
195
+ const { plans, stored } = await recorded(movedDoc(digest("c")));
196
+ const status = await statusOf(plans, [...stored, other], { "pr-7": [approval(other)] });
197
+ expect(status.state).toBe("pending");
198
+ const bare: HeadPlans = { ...plans, waves: plans.waves.map(({ changeSet: _c, ...w }) => w) };
199
+ expect(await statusOf(bare, stored, {})).toMatchObject({ state: "pending", description: expect.stringContaining("carry no change set") });
200
+ });
201
+
202
+ test("a wave whose gate does not hold the head's plan is success without an approval", async () => {
203
+ const never = { ...spec, waves: spec.waves.map((w) => ({ ...w, gate: "never" as const })) };
204
+ const { plans, stored } = await recorded(doc(digest("a")));
205
+ const status = await approvalStatusOf({
206
+ spec: never,
207
+ specFile: ".chant/op-waves/pulumi-up.spec.json",
208
+ forge,
209
+ pr: 7,
210
+ head: HEAD,
211
+ base: "b".repeat(40),
212
+ show: () => ({ sha: "b".repeat(40), text: JSON.stringify(never) }),
213
+ readPlans: async () => plans,
214
+ readResolutions: async () => [],
215
+ changeSets: async (d) => stored.find((x) => x.digest === d),
216
+ });
217
+ expect(status).toMatchObject({ state: "success", waits: [] });
218
+ });
219
+ });
@@ -55,7 +55,7 @@ export function gitOpWaveReleasePort(opts: { cwd?: string; actor?: string } = {}
55
55
  if (got.recorded) {
56
56
  out.push({ recorded: true, env: req.env, component: req.component, digest: got.record.digest, ...(got.record.releaseDigest ? { releaseDigest: got.record.releaseDigest } : {}) });
57
57
  } else {
58
- out.push({ recorded: false, reason: got.reason === "error" ? got.error : got.detail ?? got.reason });
58
+ out.push({ recorded: false, reason: got.reason === "error" ? got.error : got.detail ?? got.reason, ...(got.reason === "error" && got.lost ? { lost: true as const } : {}) });
59
59
  }
60
60
  }
61
61
  return out;
@@ -31,10 +31,9 @@
31
31
 
32
32
  import type { OpWave, OpWaveRun, OpWavesSpec } from "./op-waves";
33
33
  import type { Release, ReleaseCut } from "../lifecycle/release-store";
34
- import { NEXT_RELEASE } from "../release-floors";
35
34
 
36
35
  /** The first chant whose op-wave applies write release records (#4615). */
37
- export const OP_WAVE_RELEASE_RECORD_FLOOR = NEXT_RELEASE;
36
+ export const OP_WAVE_RELEASE_RECORD_FLOOR = "0.124.55";
38
37
 
39
38
  /** Where an op-wave apply's release record goes (#4615), and under which names. */
40
39
  export interface OpWaveReleaseNames {
@@ -60,7 +59,7 @@ export interface OpWaveReleaseRequest {
60
59
  /** How one record came out. */
61
60
  export type OpWaveReleaseOutcome =
62
61
  | { recorded: true; env: string; component: string; digest: string; releaseDigest?: string }
63
- | { recorded: false; reason: string };
62
+ | { recorded: false; reason: string; /** The record was written and its push never landed (plywood#22 finding 9). */ lost?: true };
64
63
 
65
64
  /** Where an op wave job's release records go (#4615). */
66
65
  export interface OpWaveReleasePort {
@@ -88,7 +88,7 @@ import type { TrustPolicy } from "../workspace/trust/policy";
88
88
  import type { GateSigners } from "../lifecycle/gate-seal";
89
89
  import { ciRunIdFromEnv } from "./gate-run-locator";
90
90
  import { appendRunRecord, DEFAULT_RUN_ENV } from "../lifecycle/run-ledger";
91
- import { pushLifecycleReport } from "../lifecycle/git";
91
+ import { LifecyclePushLostError, pushLifecycleRebasing } from "../lifecycle/git";
92
92
  import { resolveCiJob } from "../lifecycle/release-ledger";
93
93
  import type { OpRunPolicyRow, OpRunRecordInput, OpRunStepRecord, OpRunWave, OpRunWavePlan, OpRunWaveTarget } from "./runtime";
94
94
  import { foldPolicyRows, opWaveAfterPlanProblems, runOpWaveAfterPlanHooks, type OpWaveAfterPlanHook, type OpWaveAfterPlanRun } from "./op-waves-after-plan";
@@ -104,6 +104,7 @@ import type { LockGrain } from "../lifecycle/lock-rows";
104
104
  import type { LockLiveness } from "../lifecycle/resource-lock";
105
105
  import type { GatePolicyExec } from "../gate-policy";
106
106
  import { gitOpWaveNewerCommit, opWaveStandDownReason, tipAppliesTargets, type OpWaveNewerCommitPort } from "./op-waves-stand-down";
107
+ import { mapLimited } from "../parallelism";
107
108
  import {
108
109
  applyOpWaveStep,
109
110
  opWaveCosts,
@@ -679,7 +680,10 @@ function pointAtBase(spec: OpWavesSpec, name: string, where: string): Pick<OpWav
679
680
  return { point: opWavePointAt(spec, name)! };
680
681
  }
681
682
 
682
- /** Where a run's plan file goes. */
683
+ /** The first chant whose op entry exports {@link opWavePlanPath} (terragucci#1304). */
684
+ export const OP_WAVE_PLAN_PATH_FLOOR = "0.124.56";
685
+
686
+ /** Where a run's plan file goes: one target's plan, as opposed to {@link opWavePlansPath}, the wave's `plans.json`. */
683
687
  export function opWavePlanPath(spec: Pick<OpWavesSpec, "name">, wave: number, target: string): string {
684
688
  return `.chant/op-waves/${spec.name}/wave-${wave}/${target.replace(/[^A-Za-z0-9._-]/g, "_")}.plan.json`;
685
689
  }
@@ -785,6 +789,14 @@ export interface RunOpWaveOptions {
785
789
  lockGate?: string;
786
790
  /** Whether a run holding rows still runs (#4552). Default: the forge's answer, with the lease's age. */
787
791
  lockLiveness?: LockLiveness;
792
+ /**
793
+ * How long a wave on the `target` or `repo` grain waits for its rows, in
794
+ * seconds (ruling for ci-products 2026-10-28). Default `CHANT_LOCK_WAIT`,
795
+ * which the waves pipelines set from the job's timeout.
796
+ */
797
+ lockWaitSeconds?: number;
798
+ /** How often a waiting wave reads the rows file again, in ms. Default `CHANT_LOCK_POLL` seconds, else 10 s. */
799
+ lockPollMs?: number;
788
800
  /** Overrides the spec's `standDown` (#4581). */
789
801
  standDown?: boolean;
790
802
  /** How the job finds a newer commit on its branch (#4581). Default: fetch the branch from `origin` ({@link gitOpWaveNewerCommit}). */
@@ -828,7 +840,8 @@ export function gitOpWaveRunPort(opts?: { cwd?: string }): OpWaveRunPort {
828
840
  return {
829
841
  async append(record) {
830
842
  await appendRunRecord(record, opts);
831
- const { pushWarning } = await pushLifecycleReport(opts);
843
+ // plywood#22 finding 9: a push another writer beat replays on its tip and pushes again; one that never lands throws LifecyclePushLostError.
844
+ const { pushWarning } = await pushLifecycleRebasing(opts);
832
845
  return pushWarning ? { pushWarning } : {};
833
846
  },
834
847
  };
@@ -1095,36 +1108,88 @@ async function declaredLockGrain(cwd: string, base: string | undefined): Promise
1095
1108
  }
1096
1109
 
1097
1110
  /**
1098
- * Lease the rows of a wave's runs on the resource grain (#4552), before
1099
- * anything of the wave applies, all in one take. A held row makes the wave
1100
- * apply nothing with the `held` outcome, exit 5, naming the run that holds it.
1111
+ * Lease the rows of a wave's runs (#4552), before anything of the wave
1112
+ * applies. First the rows its runs on the `target` and `repo` grains wait
1113
+ * for (ruling for ci-products 2026-10-28, "Ledger lock"): a stock Pulumi
1114
+ * stack's `stack` row, a Terraform root's `root` row, the `repo` row. The
1115
+ * wave waits for them in the ledger's queue, oldest commit first, up to
1116
+ * `lockWaitSeconds` (`CHANT_LOCK_WAIT`, set from the job's timeout), and at
1117
+ * the deadline applies nothing with the `held` outcome, exit 5. Then the rows
1118
+ * of its runs on the resource grain, all in one take with no wait: a held row
1119
+ * makes the wave apply nothing with the `held` outcome, exit 5, naming the
1120
+ * run that holds it. A run whose plan changes nothing takes no row, and
1121
+ * outside a git work tree the waiting grains take none.
1101
1122
  */
1102
1123
  async function leaseWaveRows(
1103
1124
  options: RunOpWaveOptions,
1104
1125
  ctx: WaveContext,
1105
1126
  runs: readonly OpWaveRun[],
1106
1127
  ): Promise<{ release(): Promise<boolean> } | OpWaveApplyOutcome | { failed: string } | undefined> {
1107
- const rows = runs.flatMap((r) => {
1108
- const lock = ctx.steps?.get(r.target)?.lock;
1109
- return lock?.grain === "resource" ? lock.rows : [];
1128
+ const locks = runs.flatMap((r) => {
1129
+ const plan = ctx.steps?.get(r.target);
1130
+ return plan?.lock && !plan.empty ? [plan.lock] : [];
1110
1131
  });
1111
- if (rows.length === 0) return undefined;
1112
- const { leaseLockRows } = await import("../lifecycle/resource-lock");
1132
+ const rows = locks.flatMap((l) => (l.grain === "resource" ? l.rows : []));
1133
+ // Outside a git work tree no ledger holds a queue, so a waiting grain takes no row there, as `chant run --components` takes none.
1134
+ const queued = locks.flatMap((l) => (l.grain !== "resource" ? (l.queue ?? []) : []));
1135
+ const queue = queued.length > 0 && inGitWorkTree(ctx.cwd) ? queued : [];
1136
+ if (rows.length === 0 && queue.length === 0) return undefined;
1137
+ const { commitTimeOf, leaseLockRows, lockPollMs, lockWaitSeconds } = await import("../lifecycle/resource-lock");
1113
1138
  const { PR_APPLY_GATE } = await import("../pr-loop");
1114
1139
  const gate = options.lockGate ?? PR_APPLY_GATE;
1115
- let leased: Awaited<ReturnType<typeof leaseLockRows>>;
1116
- try {
1117
- leased = await leaseLockRows(gate, rows, { cwd: ctx.cwd, ...(options.lockLiveness ? { alive: options.lockLiveness } : {}) });
1118
- } catch (err) {
1119
- return { failed: `wave ${ctx.k} (${ctx.wave.name}): could not hold the rows its runs change in ${gate}, so nothing was applied: ${err instanceof Error ? err.message : String(err)}` };
1140
+ const label = `wave ${ctx.k} (${ctx.wave.name})`;
1141
+ const alive = options.lockLiveness ? { alive: options.lockLiveness } : {};
1142
+ const held: Array<{ release(): Promise<boolean> }> = [];
1143
+ const releaseAll = async () => {
1144
+ let ok = true;
1145
+ for (const l of held.reverse()) ok = (await l.release()) && ok;
1146
+ return ok;
1147
+ };
1148
+ const take = async (wanted: typeof rows, wait: boolean): Promise<OpWaveApplyOutcome | { failed: string } | undefined> => {
1149
+ if (wanted.length === 0) return undefined;
1150
+ let leased: Awaited<ReturnType<typeof leaseLockRows>>;
1151
+ try {
1152
+ const waitFor = wait
1153
+ ? {
1154
+ wait: {
1155
+ deadline: Date.now() + (options.lockWaitSeconds ?? lockWaitSeconds(process.env)) * 1000,
1156
+ pollMs: options.lockPollMs ?? lockPollMs(process.env),
1157
+ log: (line: string) => ctx.log(`${label}: ${line}`),
1158
+ ...(await commitTimeOf(options.head ?? "HEAD", ctx.cwd).then((t) => (t ? { commitAt: t } : {}))),
1159
+ },
1160
+ }
1161
+ : {};
1162
+ leased = await leaseLockRows(gate, wanted, { cwd: ctx.cwd, ...alive, ...waitFor });
1163
+ } catch (err) {
1164
+ return { failed: `${label}: could not hold the rows its runs change in ${gate}, so nothing was applied: ${err instanceof Error ? err.message : String(err)}` };
1165
+ }
1166
+ if (!leased.ok) {
1167
+ const first = leased.held[0]?.holder;
1168
+ const reason = leased.timedOut ? `LockWaitTimeoutError: ${leased.message}` : leased.message;
1169
+ return { outcome: "held", reason, ...(first ? { holder: { run: first.run, ...(first.url ? { url: first.url } : {}) } } : {}) };
1170
+ }
1171
+ for (const h of leased.tookOver) ctx.log(`${label}: took over the rows of run ${h.run}, which is gone`);
1172
+ const waited = leased.waited ? ` after waiting ${leased.waitedSeconds ?? 0}s` : "";
1173
+ ctx.log(`${label}: holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${gate}${waited} while it applies`);
1174
+ held.push(leased.lease);
1175
+ return undefined;
1176
+ };
1177
+ for (const [wanted, wait] of [[queue, true], [rows, false]] as const) {
1178
+ const stop = await take(wanted, wait);
1179
+ if (stop) {
1180
+ if (!(await releaseAll())) ctx.log(`${label}: could not let go of the rows it held; the next apply takes them over once this run is gone`);
1181
+ return stop;
1182
+ }
1120
1183
  }
1121
- if (!leased.ok) {
1122
- const first = leased.held[0]!.holder;
1123
- return { outcome: "held", reason: leased.message, holder: { run: first.run, ...(first.url ? { url: first.url } : {}) } };
1184
+ return { release: releaseAll };
1185
+ }
1186
+
1187
+ function inGitWorkTree(cwd: string): boolean {
1188
+ try {
1189
+ return execFileSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim() === "true";
1190
+ } catch {
1191
+ return false;
1124
1192
  }
1125
- for (const h of leased.tookOver) ctx.log(`wave ${ctx.k} (${ctx.wave.name}): took over the rows of run ${h.run}, which is gone`);
1126
- ctx.log(`wave ${ctx.k} (${ctx.wave.name}): holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${gate} while it applies`);
1127
- return leased.lease;
1128
1193
  }
1129
1194
 
1130
1195
  /** A wave's cost hold over its plans (#4545): each changing run priced, the sum against `approveAbove`. */
@@ -1777,12 +1842,14 @@ export async function runOpWave(options: RunOpWaveOptions): Promise<RunOpWaveRes
1777
1842
  try {
1778
1843
  result = await runOpWaveJob(options);
1779
1844
  } catch (err) {
1780
- const record = await recordOpWaveRun(options, started, { error: err });
1845
+ const { lost: _lost, ...record } = await recordOpWaveRun(options, started, { error: err });
1781
1846
  await closeOpWaveEvents(options, events, record);
1782
1847
  throw err;
1783
1848
  }
1784
- const record = await recordOpWaveRun(options, started, { result });
1849
+ const { lost, ...record } = await recordOpWaveRun(options, started, { result });
1785
1850
  await closeOpWaveEvents(options, events, record, result);
1851
+ // plywood#22 finding 9: a run record that never reached the remote fails a job that would have passed.
1852
+ if (lost !== undefined && result.exitCode === CHANT_EXIT.done) result.exitCode = CHANT_EXIT.failed;
1786
1853
  return result;
1787
1854
  }
1788
1855
 
@@ -1832,6 +1899,11 @@ function targetSettled(options: RunOpWaveOptions, result: RunOpWaveResult, k: nu
1832
1899
  durationMs,
1833
1900
  ...(opts.facts?.attributes ? { attributes: opts.facts.attributes } : {}),
1834
1901
  ...(opts.facts?.spans?.length ? { spans: opts.facts.spans } : {}),
1902
+ // #4629: what the failed-apply triage reads back from the run record.
1903
+ ...(status === "failed" && opts.error ? { error: opts.error } : {}),
1904
+ ...(status === "failed" && opts.facts?.resources?.some((r) => r.status === "failed")
1905
+ ? { failedResources: opts.facts.resources.filter((r) => r.status === "failed").map((r) => r.name ?? r.resource) }
1906
+ : {}),
1835
1907
  },
1836
1908
  };
1837
1909
  jobEvents.get(options)?.stepSettle(k, target, status, durationMs, opts);
@@ -1940,8 +2012,13 @@ export function opWaveRunRecord(
1940
2012
  };
1941
2013
  }
1942
2014
 
1943
- /** Append the job's run record (#4551). A failed write warns and never changes the job's exit code. */
1944
- async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outcome: { result: RunOpWaveResult } | { error: unknown }): Promise<OpRunRecordInput> {
2015
+ /**
2016
+ * Append the job's run record (#4551). A failed write warns and never
2017
+ * changes the job's exit code, except a record whose push never landed
2018
+ * after its replays (`LifecyclePushLostError`, plywood#22 finding 9): that
2019
+ * fails the job by name, through `lost`.
2020
+ */
2021
+ async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outcome: { result: RunOpWaveResult } | { error: unknown }): Promise<OpRunRecordInput & { lost?: string }> {
1945
2022
  const cwd = options.cwd ?? process.cwd();
1946
2023
  const port = options.runs ?? (options.gates ? undefined : gitOpWaveRunPort({ cwd }));
1947
2024
  const log = options.log ?? ((line: string) => console.error(line));
@@ -1961,7 +2038,12 @@ async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outco
1961
2038
  const wrote = await port.append(record);
1962
2039
  if (wrote && wrote.pushWarning) log(`wave ${options.wave}: the run record was written and not pushed: ${wrote.pushWarning}`);
1963
2040
  } catch (err) {
1964
- log(`wave ${options.wave}: could not record the run on the run ledger: ${err instanceof Error ? err.message : String(err)}`);
2041
+ const message = err instanceof Error ? err.message : String(err);
2042
+ if (err instanceof LifecyclePushLostError) {
2043
+ log(`wave ${options.wave}: LifecyclePushLostError: the run record was written and never reached the remote, so the job fails: ${message}`);
2044
+ return Object.assign(record, { lost: message });
2045
+ }
2046
+ log(`wave ${options.wave}: could not record the run on the run ledger: ${message}`);
1965
2047
  }
1966
2048
  return record;
1967
2049
  }
@@ -3398,6 +3480,9 @@ async function applyLeased(
3398
3480
  log(`wave ${k} (${wave.name}): apply failed, so none of ${runs.map((r) => r.target).join(", ")} counts as applied`);
3399
3481
  result.failed.push(...runs.map((r) => r.target));
3400
3482
  }
3483
+ } else if (spec.step && (wave.parallelism ?? spec.parallelism ?? 1) > 1) {
3484
+ // #4625: the step's runs apply several at once.
3485
+ await applyStepRunsAtOnce(options, ctx, runs, wave.parallelism ?? spec.parallelism!);
3401
3486
  } else {
3402
3487
  const order = new Map(runs.map((r, i) => [r.target, i]));
3403
3488
  for (const [i, run] of runs.entries()) {
@@ -3496,10 +3581,66 @@ async function applyLeased(
3496
3581
  if (recordPath && result.hooks.length > 0) writeRecord(recordPath, decision, result);
3497
3582
  }
3498
3583
 
3584
+ /**
3585
+ * A wave's step runs applied at most `limit` at once (#4625). A run waits
3586
+ * for each run the wave lists before it that it depends on, and is blocked,
3587
+ * as one at a time, when that one failed or was blocked. The outcomes land
3588
+ * in the result in the wave's order.
3589
+ */
3590
+ async function applyStepRunsAtOnce(options: RunOpWaveOptions, ctx: WaveContext, runs: readonly OpWaveRun[], limit: number): Promise<void> {
3591
+ const { spec, k, wave, log, result } = ctx;
3592
+ type Outcome = { applied: true } | { failed: true } | { moved: true } | { blockedBy: string };
3593
+ const order = new Map(runs.map((r, i) => [r.target, i]));
3594
+ const registry = await opWaveRegistry(options, ctx.cwd, options.capabilities);
3595
+ const settled = new Map<string, Promise<Outcome>>();
3596
+ const outcomes = await mapLimited(runs, limit, (run, i) => {
3597
+ const going = (async (): Promise<Outcome> => {
3598
+ const earlier = (run.dependsOn ?? []).filter((d) => (order.get(d) ?? Infinity) < i).sort();
3599
+ for (const dep of earlier) {
3600
+ const got = await settled.get(dep)!;
3601
+ if ("failed" in got || "blockedBy" in got) {
3602
+ const by = "blockedBy" in got ? got.blockedBy : dep;
3603
+ log(`${run.target}: blocked by ${by}, so not applied`);
3604
+ return { blockedBy: by };
3605
+ }
3606
+ }
3607
+ const plan = ctx.steps?.get(run.target);
3608
+ if (!plan) {
3609
+ log(`${run.target}: this job holds no plan of it to apply`);
3610
+ return { failed: true };
3611
+ }
3612
+ const startedMs = targetStarted(options, k, run.target);
3613
+ const got = await applyOpWaveStep({ spec, wave, registry }, run, plan);
3614
+ targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "moved" ? "skipped" : "failed", {
3615
+ ...(got.outcome !== "applied" ? { error: got.reason } : {}),
3616
+ ...(got.facts ? { facts: got.facts } : {}),
3617
+ });
3618
+ if (got.outcome === "applied") return { applied: true };
3619
+ if (got.outcome === "moved") {
3620
+ log(`${run.target}: its plan moved since wave ${k} was decided, so it was not applied: ${got.reason}`);
3621
+ return { moved: true };
3622
+ }
3623
+ log(`${run.target}: apply failed: ${got.reason}`);
3624
+ return { failed: true };
3625
+ })();
3626
+ settled.set(run.target, going);
3627
+ return going;
3628
+ });
3629
+ for (const [i, got] of outcomes.entries()) {
3630
+ const target = runs[i]!.target;
3631
+ if ("applied" in got) result.applied.push(target);
3632
+ else if ("moved" in got) result.moved.push(target);
3633
+ else if ("failed" in got) result.failed.push(target);
3634
+ else result.blocked = { ...result.blocked, [target]: got.blockedBy };
3635
+ }
3636
+ }
3637
+
3499
3638
  /**
3500
3639
  * The release records of the runs this wave applied through its step
3501
3640
  * (#4615), one per run, on the environment ledger each names. A record that
3502
- * is not written is a line in the log; the job's exit code stays.
3641
+ * is not written is a line in the log and the job's exit code stays, except
3642
+ * one written whose push never landed after its replays (plywood#22 finding
3643
+ * 9), which fails the wave by name.
3503
3644
  */
3504
3645
  async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[]): Promise<void> {
3505
3646
  const { spec, k, wave, log, result } = ctx;
@@ -3534,6 +3675,7 @@ async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, d
3534
3675
  for (const [i, req] of requests.entries()) {
3535
3676
  const got = outcomes[i];
3536
3677
  if (got?.recorded) log(`${req.target}: recorded on the "${got.env}" release ledger as ${got.component} ${got.digest}${got.releaseDigest ? ` under release ${got.releaseDigest}` : ""}`);
3678
+ else if (got && !got.recorded && got.lost) failed(ctx, `${req.target}: applied, and LifecyclePushLostError: the release record for ${req.component} in "${req.env}" was written and never reached the remote, so the wave fails: ${got.reason}`);
3537
3679
  else log(`${req.target}: applied, and no release record was written for ${req.component} in "${req.env}": ${got?.reason ?? "the port gave no answer"}`);
3538
3680
  }
3539
3681
  }
@@ -3647,6 +3789,8 @@ export interface RecordHeadPlansOptions {
3647
3789
  now?: string;
3648
3790
  /** Write the record. Default: append to `chant/lifecycle` and push. */
3649
3791
  write?: (plans: HeadPlans) => Promise<void>;
3792
+ /** Store a wave's change set at the head (#4630). Default: `_change-sets/` on `chant/lifecycle`, pushed with the record. */
3793
+ storeChangeSet?: (doc: ChangeSetDocument) => Promise<void>;
3650
3794
  /** The capabilities a spec's `step` plans through (#4545). Default: the project's at `cwd`. */
3651
3795
  capabilities?: CapabilityRegistry;
3652
3796
  /** How a cost hold's estimator runs (#4545). */
@@ -3658,7 +3802,8 @@ export interface RecordHeadPlansOptions {
3658
3802
  * pull request's head and record each wave's digest on `chant/lifecycle`,
3659
3803
  * `_wave-plans/<name>/<head>.json`. A `pr-review` wave reads it after the
3660
3804
  * merge: the review of that head approves the digests it planned, and only
3661
- * those.
3805
+ * those. A wave whose plans file gives a change set records its digest and
3806
+ * stores it (#4630), for the approval status of a `pull-request` wave.
3662
3807
  */
3663
3808
  export async function recordOpWaveHeadPlans(options: RecordHeadPlansOptions): Promise<HeadPlans> {
3664
3809
  const { spec } = options;
@@ -3674,22 +3819,42 @@ export async function recordOpWaveHeadPlans(options: RecordHeadPlansOptions): Pr
3674
3819
  timestamp: options.now ?? new Date().toISOString(),
3675
3820
  waves: [],
3676
3821
  };
3822
+ const changeSets: ChangeSetDocument[] = [];
3677
3823
  // A `rest` wave (#3821) goes on through the waves the plan command found.
3678
3824
  const last = spec.waves[spec.waves.length - 1]!;
3679
3825
  for (let k = 1; ; k++) {
3680
3826
  const wave = spec.waves[k - 1] ?? last;
3681
3827
  const steps = new Map<string, OpWaveStepPlan>();
3682
- const { members, extras: planExtras, waves: found } = await planWaveRuns({ spec, k, wave, cwd, exec, options, steps }, wave.runs, wave.discover === true);
3828
+ const { members, extras: planExtras, waves: found, changeSet } = await planWaveRuns({ spec, k, wave, cwd, exec, options, steps }, wave.runs, wave.discover === true);
3683
3829
  // #4545: a cost hold's member is in the digest the merged wave decides, so the head's digest carries it too.
3684
3830
  const cost = spec.holds?.cost ? costVerdictOf(spec.holds.cost, spec, k, members, steps, cwd, options.holdExec).member : undefined;
3685
3831
  const extras = cost ? [...(planExtras ?? []), cost] : planExtras;
3686
- plans.waves.push({ wave: k, name: wave.name, digest: opWaveSetDigest(spec, members, extras) });
3832
+ // #4630: the facts a gate policy reads, so the approval status before merge says which waves will wait.
3833
+ plans.waves.push({
3834
+ wave: k,
3835
+ name: wave.name,
3836
+ digest: opWaveSetDigest(spec, members, extras),
3837
+ changes: !members.every((m) => m.empty === true),
3838
+ destructive: members.some((m) => m.destructive === true),
3839
+ // #4630: a pull-request wave's change set, which the pull request's own approval must cover.
3840
+ ...(changeSet ? { changeSet: changeSet.digest } : {}),
3841
+ });
3842
+ if (changeSet) changeSets.push(changeSet);
3687
3843
  if (k >= spec.waves.length && !(last.rest && found !== undefined && k < found)) break;
3688
3844
  }
3845
+ // The change sets go on the ledger first, so the record's push carries them.
3846
+ for (const doc of changeSets) await (options.storeChangeSet ?? ((d) => storeHeadChangeSet(d, cwd)))(doc);
3689
3847
  await (options.write ?? ((p) => writeHeadPlans(p, cwd)))(plans);
3690
3848
  return plans;
3691
3849
  }
3692
3850
 
3851
+ async function storeHeadChangeSet(doc: ChangeSetDocument, cwd: string): Promise<void> {
3852
+ const { requireLifecycleLedger } = await import("../lifecycle/git");
3853
+ const { persistChangeSet } = await import("../lifecycle/change-set-store");
3854
+ await requireLifecycleLedger({ cwd });
3855
+ await persistChangeSet(doc, { cwd });
3856
+ }
3857
+
3693
3858
  async function writeHeadPlans(plans: HeadPlans, cwd: string): Promise<void> {
3694
3859
  const { pushLifecycle, requireLifecycleLedger, writeBlobToPath } = await import("../lifecycle/git");
3695
3860
  const { headPlansPath } = await import("./gate-review");
@@ -27,7 +27,6 @@
27
27
  import { execFile } from "node:child_process";
28
28
  import { promisify } from "node:util";
29
29
  import type { OpWavesSpec } from "./op-waves";
30
- import { NEXT_RELEASE } from "../release-floors";
31
30
 
32
31
  const exec = promisify(execFile);
33
32
 
@@ -37,7 +36,7 @@ const exec = promisify(execFile);
37
36
  * export of {@link newerCommitOnBranch} from `@intentius/chant/op`, before
38
37
  * it drops its copy.
39
38
  */
40
- export const OP_WAVE_STAND_DOWN_FLOOR = NEXT_RELEASE;
39
+ export const OP_WAVE_STAND_DOWN_FLOOR = "0.124.55";
41
40
 
42
41
  /** A newer commit on the run's branch. */
43
42
  export interface OpWaveNewerCommit {