@intentius/chant 0.124.52 → 0.124.55

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 (1337) hide show
  1. package/dist/__fixtures__/estate-ledger.d.ts +13 -0
  2. package/dist/__fixtures__/estate-ledger.d.ts.map +1 -0
  3. package/dist/__fixtures__/estate-ledger.js +67 -0
  4. package/dist/__fixtures__/oidc-emulator.d.ts +11 -1
  5. package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -1
  6. package/dist/__fixtures__/oidc-emulator.js +26 -2
  7. package/dist/__fixtures__/product-words.d.ts +78 -0
  8. package/dist/__fixtures__/product-words.d.ts.map +1 -0
  9. package/dist/__fixtures__/product-words.js +43 -0
  10. package/dist/__golden__/wave-loop/op-by-apply-after-fails.json +10 -2
  11. package/dist/__golden__/wave-loop/op-by-apply-hold.json +20 -4
  12. package/dist/__golden__/wave-loop/op-by-apply-ignored.json +10 -2
  13. package/dist/__golden__/wave-loop/op-by-apply-pass.json +10 -2
  14. package/dist/__golden__/wave-loop/op-by-apply-skip.json +10 -2
  15. package/dist/__golden__/wave-loop/op-discover-rest-stops.json +22 -6
  16. package/dist/__golden__/wave-loop/op-discover-rest.json +44 -12
  17. package/dist/__golden__/wave-loop/op-discover-wide.json +12 -3
  18. package/dist/__golden__/wave-loop/op-held-on.json +28 -7
  19. package/dist/__golden__/wave-loop/op-hooks-apply-fails.json +22 -6
  20. package/dist/__golden__/wave-loop/op-hooks-fail-after-apply.json +22 -6
  21. package/dist/__golden__/wave-loop/op-hooks-fail-before-apply.json +4 -2
  22. package/dist/__golden__/wave-loop/op-hooks-held.json +26 -8
  23. package/dist/__golden__/wave-loop/op-hooks-hold-before-apply.json +18 -4
  24. package/dist/__golden__/wave-loop/op-hooks-pass.json +22 -6
  25. package/dist/__golden__/wave-loop/op-hooks-share.json +20 -7
  26. package/dist/__golden__/wave-loop/op-outcome-held.json +12 -3
  27. package/dist/__golden__/wave-loop/op-outcome-replan-approved.json +16 -5
  28. package/dist/__golden__/wave-loop/op-outcome-replan-forever.json +48 -21
  29. package/dist/__golden__/wave-loop/op-outcome-replan.json +16 -5
  30. package/dist/__golden__/wave-loop/op-outcome-stood-down.json +12 -3
  31. package/dist/__golden__/wave-loop/op-outcome-unreadable.json +12 -3
  32. package/dist/__golden__/wave-loop/op-overridden.json +28 -7
  33. package/dist/__golden__/wave-loop/op-per-run.json +20 -4
  34. package/dist/__golden__/wave-loop/op-point.json +18 -4
  35. package/dist/__golden__/wave-loop/op-pr-review.json +10 -2
  36. package/dist/__golden__/wave-loop/op-spend-change-only.json +10 -2
  37. package/dist/__golden__/wave-loop/op-spend.json +10 -2
  38. package/dist/__golden__/wave-loop/op-wave-commands.json +56 -13
  39. package/dist/__golden__/wave-loop/op-wide.json +20 -4
  40. package/dist/audit/discover.d.ts.map +1 -1
  41. package/dist/audit/discover.js +3 -1
  42. package/dist/behaviour.d.ts +1 -1
  43. package/dist/behaviour.d.ts.map +1 -1
  44. package/dist/bucket-check/azure.d.ts +108 -0
  45. package/dist/bucket-check/azure.d.ts.map +1 -0
  46. package/dist/bucket-check/azure.js +258 -0
  47. package/dist/bucket-check/fixtures/azure.json +153 -0
  48. package/dist/bucket-check/fixtures/gcs.json +148 -0
  49. package/dist/bucket-check/fixtures/s3.json +277 -0
  50. package/dist/bucket-check/gcs.d.ts +77 -0
  51. package/dist/bucket-check/gcs.d.ts.map +1 -0
  52. package/dist/bucket-check/gcs.js +202 -0
  53. package/dist/bucket-check/index.d.ts +48 -0
  54. package/dist/bucket-check/index.d.ts.map +1 -0
  55. package/dist/bucket-check/index.js +44 -0
  56. package/dist/bucket-check/s3.d.ts +116 -0
  57. package/dist/bucket-check/s3.d.ts.map +1 -0
  58. package/dist/bucket-check/s3.js +362 -0
  59. package/dist/bucket-check/types.d.ts +66 -0
  60. package/dist/bucket-check/types.d.ts.map +1 -0
  61. package/dist/bucket-check/types.js +31 -0
  62. package/dist/bucket-check/wire.d.ts +27 -0
  63. package/dist/bucket-check/wire.d.ts.map +1 -0
  64. package/dist/bucket-check/wire.js +32 -0
  65. package/dist/bucket-check.d.ts +6 -0
  66. package/dist/bucket-check.d.ts.map +1 -0
  67. package/dist/bucket-check.js +5 -0
  68. package/dist/capabilities/templates.d.ts +65 -0
  69. package/dist/capabilities/templates.d.ts.map +1 -0
  70. package/dist/capabilities/templates.js +192 -0
  71. package/dist/capabilities/templates.json +145 -0
  72. package/dist/change-set-graph.d.ts +35 -3
  73. package/dist/change-set-graph.d.ts.map +1 -1
  74. package/dist/change-set-graph.js +60 -9
  75. package/dist/change-set.d.ts +65 -7
  76. package/dist/change-set.d.ts.map +1 -1
  77. package/dist/change-set.js +22 -12
  78. package/dist/ci-agent.d.ts +381 -0
  79. package/dist/ci-agent.d.ts.map +1 -0
  80. package/dist/ci-agent.js +833 -0
  81. package/dist/ci-control.d.ts +42 -0
  82. package/dist/ci-control.d.ts.map +1 -0
  83. package/dist/ci-control.js +42 -0
  84. package/dist/ci-estate/delivery.d.ts +137 -0
  85. package/dist/ci-estate/delivery.d.ts.map +1 -0
  86. package/dist/ci-estate/delivery.js +311 -0
  87. package/dist/ci-estate/overdue.d.ts +34 -0
  88. package/dist/ci-estate/overdue.d.ts.map +1 -0
  89. package/dist/ci-estate/overdue.js +58 -0
  90. package/dist/ci-estate/page.d.ts +134 -0
  91. package/dist/ci-estate/page.d.ts.map +1 -0
  92. package/dist/ci-estate/page.js +233 -0
  93. package/dist/ci-estate/rows.d.ts +118 -0
  94. package/dist/ci-estate/rows.d.ts.map +1 -0
  95. package/dist/ci-estate/rows.js +126 -0
  96. package/dist/ci-estate.d.ts +68 -0
  97. package/dist/ci-estate.d.ts.map +1 -0
  98. package/dist/ci-estate.js +83 -0
  99. package/dist/ci-handover.d.ts +29 -5
  100. package/dist/ci-handover.d.ts.map +1 -1
  101. package/dist/ci-handover.js +50 -16
  102. package/dist/ci-identity.d.ts +89 -9
  103. package/dist/ci-identity.d.ts.map +1 -1
  104. package/dist/ci-identity.js +91 -16
  105. package/dist/ci-product-words.d.ts +290 -0
  106. package/dist/ci-product-words.d.ts.map +1 -0
  107. package/dist/ci-product-words.js +373 -0
  108. package/dist/ci-product.d.ts +82 -0
  109. package/dist/ci-product.d.ts.map +1 -0
  110. package/dist/ci-product.js +78 -0
  111. package/dist/cli/commands/audit.d.ts +2 -2
  112. package/dist/cli/commands/audit.d.ts.map +1 -1
  113. package/dist/cli/commands/audit.js +3 -2
  114. package/dist/cli/commands/carve.js +2 -2
  115. package/dist/cli/commands/import-index.d.ts +52 -0
  116. package/dist/cli/commands/import-index.d.ts.map +1 -0
  117. package/dist/cli/commands/import-index.js +226 -0
  118. package/dist/cli/commands/init.d.ts +2 -0
  119. package/dist/cli/commands/init.d.ts.map +1 -1
  120. package/dist/cli/commands/init.js +1 -1
  121. package/dist/cli/commands/lint.d.ts.map +1 -1
  122. package/dist/cli/commands/lint.js +4 -2
  123. package/dist/cli/handlers/agent.d.ts +17 -0
  124. package/dist/cli/handlers/agent.d.ts.map +1 -0
  125. package/dist/cli/handlers/agent.js +114 -0
  126. package/dist/cli/handlers/approve-confirm.d.ts +84 -0
  127. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -0
  128. package/dist/cli/handlers/approve-confirm.js +142 -0
  129. package/dist/cli/handlers/approve.d.ts.map +1 -1
  130. package/dist/cli/handlers/approve.js +19 -1
  131. package/dist/cli/handlers/build.d.ts.map +1 -1
  132. package/dist/cli/handlers/build.js +43 -1
  133. package/dist/cli/handlers/ci-check.d.ts +3 -0
  134. package/dist/cli/handlers/ci-check.d.ts.map +1 -0
  135. package/dist/cli/handlers/ci-check.js +34 -0
  136. package/dist/cli/handlers/ci-forge-check.d.ts +3 -0
  137. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -0
  138. package/dist/cli/handlers/ci-forge-check.js +89 -0
  139. package/dist/cli/handlers/components.d.ts.map +1 -1
  140. package/dist/cli/handlers/components.js +11 -2
  141. package/dist/cli/handlers/fan-out.d.ts.map +1 -1
  142. package/dist/cli/handlers/fan-out.js +20 -3
  143. package/dist/cli/handlers/gate-pending.d.ts +11 -0
  144. package/dist/cli/handlers/gate-pending.d.ts.map +1 -0
  145. package/dist/cli/handlers/gate-pending.js +44 -0
  146. package/dist/cli/handlers/graph.d.ts.map +1 -1
  147. package/dist/cli/handlers/graph.js +22 -4
  148. package/dist/cli/handlers/index-cloud.d.ts +14 -0
  149. package/dist/cli/handlers/index-cloud.d.ts.map +1 -0
  150. package/dist/cli/handlers/index-cloud.js +22 -0
  151. package/dist/cli/handlers/index-diff.d.ts +18 -0
  152. package/dist/cli/handlers/index-diff.d.ts.map +1 -0
  153. package/dist/cli/handlers/index-diff.js +142 -0
  154. package/dist/cli/handlers/init.d.ts.map +1 -1
  155. package/dist/cli/handlers/init.js +1 -0
  156. package/dist/cli/handlers/ledger.js +1 -1
  157. package/dist/cli/handlers/lifecycle-drift.d.ts +29 -0
  158. package/dist/cli/handlers/lifecycle-drift.d.ts.map +1 -0
  159. package/dist/cli/handlers/lifecycle-drift.js +69 -0
  160. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  161. package/dist/cli/handlers/lifecycle.js +188 -28
  162. package/dist/cli/handlers/lock.d.ts.map +1 -1
  163. package/dist/cli/handlers/lock.js +64 -5
  164. package/dist/cli/handlers/misc.d.ts +9 -0
  165. package/dist/cli/handlers/misc.d.ts.map +1 -1
  166. package/dist/cli/handlers/misc.js +77 -0
  167. package/dist/cli/handlers/notify-relay.d.ts +15 -0
  168. package/dist/cli/handlers/notify-relay.d.ts.map +1 -0
  169. package/dist/cli/handlers/notify-relay.js +130 -0
  170. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  171. package/dist/cli/handlers/pr-env.js +42 -11
  172. package/dist/cli/handlers/pr.d.ts +38 -3
  173. package/dist/cli/handlers/pr.d.ts.map +1 -1
  174. package/dist/cli/handlers/pr.js +668 -207
  175. package/dist/cli/handlers/promote.d.ts.map +1 -1
  176. package/dist/cli/handlers/promote.js +110 -17
  177. package/dist/cli/handlers/query.d.ts.map +1 -1
  178. package/dist/cli/handlers/query.js +28 -4
  179. package/dist/cli/handlers/release.d.ts.map +1 -1
  180. package/dist/cli/handlers/release.js +3 -0
  181. package/dist/cli/handlers/run-wave.d.ts +8 -0
  182. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  183. package/dist/cli/handlers/run-wave.js +71 -1
  184. package/dist/cli/handlers/run.d.ts +6 -1
  185. package/dist/cli/handlers/run.d.ts.map +1 -1
  186. package/dist/cli/handlers/run.js +86 -1
  187. package/dist/cli/handlers/scenario.d.ts.map +1 -1
  188. package/dist/cli/handlers/scenario.js +8 -7
  189. package/dist/cli/handlers/search.d.ts +34 -4
  190. package/dist/cli/handlers/search.d.ts.map +1 -1
  191. package/dist/cli/handlers/search.js +216 -36
  192. package/dist/cli/handlers/serve.d.ts.map +1 -1
  193. package/dist/cli/handlers/serve.js +10 -1
  194. package/dist/cli/main.d.ts +11 -1
  195. package/dist/cli/main.d.ts.map +1 -1
  196. package/dist/cli/main.js +179 -14
  197. package/dist/cli/mcp/ledger-tools.d.ts +36 -0
  198. package/dist/cli/mcp/ledger-tools.d.ts.map +1 -0
  199. package/dist/cli/mcp/ledger-tools.js +122 -0
  200. package/dist/cli/mcp/lifecycle-tools.d.ts.map +1 -1
  201. package/dist/cli/mcp/lifecycle-tools.js +3 -2
  202. package/dist/cli/mcp/product-tools.d.ts +78 -0
  203. package/dist/cli/mcp/product-tools.d.ts.map +1 -0
  204. package/dist/cli/mcp/product-tools.js +93 -0
  205. package/dist/cli/mcp/read-only.d.ts +34 -0
  206. package/dist/cli/mcp/read-only.d.ts.map +1 -0
  207. package/dist/cli/mcp/read-only.js +61 -0
  208. package/dist/cli/mcp/report-tools.d.ts +48 -0
  209. package/dist/cli/mcp/report-tools.d.ts.map +1 -0
  210. package/dist/cli/mcp/report-tools.js +128 -0
  211. package/dist/cli/mcp/resource-handlers.d.ts.map +1 -1
  212. package/dist/cli/mcp/resource-handlers.js +4 -3
  213. package/dist/cli/mcp/server.d.ts +28 -1
  214. package/dist/cli/mcp/server.d.ts.map +1 -1
  215. package/dist/cli/mcp/server.js +86 -15
  216. package/dist/cli/mcp/workspace-tools.js +1 -1
  217. package/dist/cli/mcp-config.d.ts +9 -2
  218. package/dist/cli/mcp-config.d.ts.map +1 -1
  219. package/dist/cli/mcp-config.js +8 -3
  220. package/dist/cli/parse-args.d.ts.map +1 -1
  221. package/dist/cli/parse-args.js +112 -5
  222. package/dist/cli/registry.d.ts +54 -1
  223. package/dist/cli/registry.d.ts.map +1 -1
  224. package/dist/cloud-lister/aws.d.ts +35 -0
  225. package/dist/cloud-lister/aws.d.ts.map +1 -0
  226. package/dist/cloud-lister/aws.js +203 -0
  227. package/dist/cloud-lister/azure.d.ts +34 -0
  228. package/dist/cloud-lister/azure.d.ts.map +1 -0
  229. package/dist/cloud-lister/azure.js +129 -0
  230. package/dist/cloud-lister/common.d.ts +40 -0
  231. package/dist/cloud-lister/common.d.ts.map +1 -0
  232. package/dist/cloud-lister/common.js +83 -0
  233. package/dist/cloud-lister/credentials.d.ts +50 -0
  234. package/dist/cloud-lister/credentials.d.ts.map +1 -0
  235. package/dist/cloud-lister/credentials.js +86 -0
  236. package/dist/cloud-lister/fakes.d.ts +27 -0
  237. package/dist/cloud-lister/fakes.d.ts.map +1 -0
  238. package/dist/cloud-lister/fakes.js +50 -0
  239. package/dist/cloud-lister/gcp.d.ts +42 -0
  240. package/dist/cloud-lister/gcp.d.ts.map +1 -0
  241. package/dist/cloud-lister/gcp.js +143 -0
  242. package/dist/cloud-lister/guard.d.ts +49 -0
  243. package/dist/cloud-lister/guard.d.ts.map +1 -0
  244. package/dist/cloud-lister/guard.js +103 -0
  245. package/dist/cloud-lister/ids.d.ts +23 -0
  246. package/dist/cloud-lister/ids.d.ts.map +1 -0
  247. package/dist/cloud-lister/ids.js +42 -0
  248. package/dist/cloud-lister/index.d.ts +67 -0
  249. package/dist/cloud-lister/index.d.ts.map +1 -0
  250. package/dist/cloud-lister/index.js +102 -0
  251. package/dist/cloud-lister/kubernetes.d.ts +64 -0
  252. package/dist/cloud-lister/kubernetes.d.ts.map +1 -0
  253. package/dist/cloud-lister/kubernetes.js +276 -0
  254. package/dist/cloud-lister/markers.d.ts +31 -0
  255. package/dist/cloud-lister/markers.d.ts.map +1 -0
  256. package/dist/cloud-lister/markers.js +73 -0
  257. package/dist/cloud-lister/mask.d.ts +31 -0
  258. package/dist/cloud-lister/mask.d.ts.map +1 -0
  259. package/dist/cloud-lister/mask.js +74 -0
  260. package/dist/cloud-lister/sigv4.d.ts +64 -0
  261. package/dist/cloud-lister/sigv4.d.ts.map +1 -0
  262. package/dist/cloud-lister/sigv4.js +104 -0
  263. package/dist/cloud-lister/transport.d.ts +55 -0
  264. package/dist/cloud-lister/transport.d.ts.map +1 -0
  265. package/dist/cloud-lister/transport.js +86 -0
  266. package/dist/cloud-lister/types.d.ts +121 -0
  267. package/dist/cloud-lister/types.d.ts.map +1 -0
  268. package/dist/cloud-lister/types.js +24 -0
  269. package/dist/components/adoption.d.ts +69 -0
  270. package/dist/components/adoption.d.ts.map +1 -0
  271. package/dist/components/adoption.js +93 -0
  272. package/dist/components/apply-lease.d.ts +19 -0
  273. package/dist/components/apply-lease.d.ts.map +1 -0
  274. package/dist/components/apply-lease.js +41 -0
  275. package/dist/components/capability-plugin-loader.d.ts.map +1 -1
  276. package/dist/components/capability-plugin-loader.js +6 -0
  277. package/dist/components/capability-plugin.d.ts +9 -0
  278. package/dist/components/capability-plugin.d.ts.map +1 -1
  279. package/dist/components/capability.d.ts +337 -5
  280. package/dist/components/capability.d.ts.map +1 -1
  281. package/dist/components/capability.js +14 -6
  282. package/dist/components/check-hooks.d.ts +113 -0
  283. package/dist/components/check-hooks.d.ts.map +1 -0
  284. package/dist/components/check-hooks.js +192 -0
  285. package/dist/components/ci-services.d.ts +57 -0
  286. package/dist/components/ci-services.d.ts.map +1 -0
  287. package/dist/components/ci-services.js +61 -0
  288. package/dist/components/cli-support.d.ts +34 -0
  289. package/dist/components/cli-support.d.ts.map +1 -1
  290. package/dist/components/cli-support.js +67 -15
  291. package/dist/components/declared-reads.d.ts +38 -0
  292. package/dist/components/declared-reads.d.ts.map +1 -0
  293. package/dist/components/declared-reads.js +131 -0
  294. package/dist/components/deploy-units.d.ts.map +1 -1
  295. package/dist/components/deploy-units.js +4 -0
  296. package/dist/components/driver.d.ts +54 -4
  297. package/dist/components/driver.d.ts.map +1 -1
  298. package/dist/components/driver.js +90 -7
  299. package/dist/components/fan-out-run.d.ts +35 -1
  300. package/dist/components/fan-out-run.d.ts.map +1 -1
  301. package/dist/components/fan-out-run.js +138 -30
  302. package/dist/components/fan-out-support.d.ts +6 -0
  303. package/dist/components/fan-out-support.d.ts.map +1 -1
  304. package/dist/components/fan-out-support.js +4 -1
  305. package/dist/components/fan-out.d.ts +28 -0
  306. package/dist/components/fan-out.d.ts.map +1 -1
  307. package/dist/components/groups.d.ts +229 -0
  308. package/dist/components/groups.d.ts.map +1 -0
  309. package/dist/components/groups.js +777 -0
  310. package/dist/components/index.d.ts +6 -2
  311. package/dist/components/index.d.ts.map +1 -1
  312. package/dist/components/index.js +4 -0
  313. package/dist/components/plan-shape-conformance.d.ts +48 -0
  314. package/dist/components/plan-shape-conformance.d.ts.map +1 -0
  315. package/dist/components/plan-shape-conformance.js +122 -0
  316. package/dist/components/pr-env-ledger.d.ts +32 -0
  317. package/dist/components/pr-env-ledger.d.ts.map +1 -0
  318. package/dist/components/pr-env-ledger.js +39 -0
  319. package/dist/components/pr-env-ports.d.ts +12 -0
  320. package/dist/components/pr-env-ports.d.ts.map +1 -1
  321. package/dist/components/pr-env-ports.js +13 -3
  322. package/dist/components/pr-env-run.d.ts +6 -0
  323. package/dist/components/pr-env-run.d.ts.map +1 -1
  324. package/dist/components/pr-env-run.js +3 -2
  325. package/dist/components/pr-environment.d.ts +31 -3
  326. package/dist/components/pr-environment.d.ts.map +1 -1
  327. package/dist/components/pr-environment.js +25 -7
  328. package/dist/components/pr-pipeline.d.ts +169 -3
  329. package/dist/components/pr-pipeline.d.ts.map +1 -1
  330. package/dist/components/pr-pipeline.js +184 -9
  331. package/dist/components/pr-policy.d.ts +26 -2
  332. package/dist/components/pr-policy.d.ts.map +1 -1
  333. package/dist/components/pr-policy.js +41 -7
  334. package/dist/components/pr-run.d.ts +104 -4
  335. package/dist/components/pr-run.d.ts.map +1 -1
  336. package/dist/components/pr-run.js +290 -41
  337. package/dist/components/pr-targets.d.ts +24 -0
  338. package/dist/components/pr-targets.d.ts.map +1 -0
  339. package/dist/components/pr-targets.js +48 -0
  340. package/dist/components/product-pipeline.d.ts +217 -0
  341. package/dist/components/product-pipeline.d.ts.map +1 -0
  342. package/dist/components/product-pipeline.js +193 -0
  343. package/dist/components/promote-rounds.d.ts +9 -0
  344. package/dist/components/promote-rounds.d.ts.map +1 -1
  345. package/dist/components/promote-rounds.js +23 -2
  346. package/dist/components/promote.d.ts +23 -0
  347. package/dist/components/promote.d.ts.map +1 -1
  348. package/dist/components/promote.js +39 -6
  349. package/dist/components/release-compile.d.ts +22 -1
  350. package/dist/components/release-compile.d.ts.map +1 -1
  351. package/dist/components/release-compile.js +85 -0
  352. package/dist/components/release-gate.d.ts +23 -1
  353. package/dist/components/release-gate.d.ts.map +1 -1
  354. package/dist/components/release-gate.js +97 -33
  355. package/dist/components/release-promote.d.ts +15 -1
  356. package/dist/components/release-promote.d.ts.map +1 -1
  357. package/dist/components/release-promote.js +67 -2
  358. package/dist/components/repo-lock.d.ts +27 -0
  359. package/dist/components/repo-lock.d.ts.map +1 -0
  360. package/dist/components/repo-lock.js +49 -0
  361. package/dist/components/row-lease.d.ts +84 -0
  362. package/dist/components/row-lease.d.ts.map +1 -0
  363. package/dist/components/row-lease.js +110 -0
  364. package/dist/components/run-groups.d.ts +58 -0
  365. package/dist/components/run-groups.d.ts.map +1 -0
  366. package/dist/components/run-groups.js +78 -0
  367. package/dist/components/starter-plugin.d.ts +1 -0
  368. package/dist/components/starter-plugin.d.ts.map +1 -1
  369. package/dist/components/starter-plugin.js +6 -1
  370. package/dist/components/verbs/index.d.ts +1 -0
  371. package/dist/components/verbs/index.d.ts.map +1 -1
  372. package/dist/components/verbs/index.js +1 -0
  373. package/dist/components/verbs/member-outputs.d.ts +187 -0
  374. package/dist/components/verbs/member-outputs.d.ts.map +1 -0
  375. package/dist/components/verbs/member-outputs.js +218 -0
  376. package/dist/components/wave-plan.d.ts +34 -0
  377. package/dist/components/wave-plan.d.ts.map +1 -1
  378. package/dist/components/wave-plan.js +54 -2
  379. package/dist/config.d.ts +60 -0
  380. package/dist/config.d.ts.map +1 -1
  381. package/dist/config.js +27 -0
  382. package/dist/control/applied.d.ts +89 -0
  383. package/dist/control/applied.d.ts.map +1 -0
  384. package/dist/control/applied.js +175 -0
  385. package/dist/control/consumers.d.ts +78 -0
  386. package/dist/control/consumers.d.ts.map +1 -0
  387. package/dist/control/consumers.js +172 -0
  388. package/dist/control/dispatch.d.ts +334 -0
  389. package/dist/control/dispatch.d.ts.map +1 -0
  390. package/dist/control/dispatch.js +519 -0
  391. package/dist/control/edges.d.ts +75 -0
  392. package/dist/control/edges.d.ts.map +1 -0
  393. package/dist/control/edges.js +133 -0
  394. package/dist/control/reconcile.d.ts +120 -0
  395. package/dist/control/reconcile.d.ts.map +1 -0
  396. package/dist/control/reconcile.js +178 -0
  397. package/dist/control/records.d.ts +187 -0
  398. package/dist/control/records.d.ts.map +1 -0
  399. package/dist/control/records.js +307 -0
  400. package/dist/deep-observation.d.ts +1 -13
  401. package/dist/deep-observation.d.ts.map +1 -1
  402. package/dist/deep-observation.js +5 -22
  403. package/dist/discovery/sandbox/bundle.d.ts.map +1 -1
  404. package/dist/discovery/sandbox/bundle.js +25 -1
  405. package/dist/drift-record.d.ts +542 -0
  406. package/dist/drift-record.d.ts.map +1 -0
  407. package/dist/drift-record.js +886 -0
  408. package/dist/engine-facts.d.ts +144 -0
  409. package/dist/engine-facts.d.ts.map +1 -0
  410. package/dist/engine-facts.js +13 -0
  411. package/dist/exit-codes.d.ts +48 -0
  412. package/dist/exit-codes.d.ts.map +1 -0
  413. package/dist/exit-codes.js +49 -0
  414. package/dist/forge-check/check.d.ts +63 -0
  415. package/dist/forge-check/check.d.ts.map +1 -0
  416. package/dist/forge-check/check.js +139 -0
  417. package/dist/forge-check/contract.d.ts +152 -0
  418. package/dist/forge-check/contract.d.ts.map +1 -0
  419. package/dist/forge-check/contract.js +118 -0
  420. package/dist/forge-check/forge.d.ts +42 -0
  421. package/dist/forge-check/forge.d.ts.map +1 -0
  422. package/dist/forge-check/forge.js +338 -0
  423. package/dist/forge-check/index.d.ts +24 -0
  424. package/dist/forge-check/index.d.ts.map +1 -0
  425. package/dist/forge-check/index.js +23 -0
  426. package/dist/forge-check/pulumi.d.ts +44 -0
  427. package/dist/forge-check/pulumi.d.ts.map +1 -0
  428. package/dist/forge-check/pulumi.js +184 -0
  429. package/dist/forge-check/read-only.d.ts +26 -0
  430. package/dist/forge-check/read-only.d.ts.map +1 -0
  431. package/dist/forge-check/read-only.js +53 -0
  432. package/dist/forge-check/trust.d.ts +94 -0
  433. package/dist/forge-check/trust.d.ts.map +1 -0
  434. package/dist/forge-check/trust.js +532 -0
  435. package/dist/forge-check/types.d.ts +80 -0
  436. package/dist/forge-check/types.d.ts.map +1 -0
  437. package/dist/forge-check/types.js +18 -0
  438. package/dist/forge-check.d.ts +6 -0
  439. package/dist/forge-check.d.ts.map +1 -0
  440. package/dist/forge-check.js +5 -0
  441. package/dist/gate-decision.d.ts +1 -0
  442. package/dist/gate-decision.d.ts.map +1 -1
  443. package/dist/gate-decision.js +2 -0
  444. package/dist/gate-policy.d.ts +47 -1
  445. package/dist/gate-policy.d.ts.map +1 -1
  446. package/dist/gate-policy.js +50 -2
  447. package/dist/graph-ir.d.ts +153 -2
  448. package/dist/graph-ir.d.ts.map +1 -1
  449. package/dist/graph-ir.js +224 -6
  450. package/dist/graph-refs.d.ts +145 -0
  451. package/dist/graph-refs.d.ts.map +1 -1
  452. package/dist/graph-refs.js +305 -0
  453. package/dist/graph-schema/fixtures/adopt.json +15 -0
  454. package/dist/graph-schema/fixtures/choudoufu.engine-graph.json +169 -0
  455. package/dist/graph-schema/fixtures/index.json +68 -0
  456. package/dist/graph-schema/fixtures/plunge.engine-graph.json +158 -0
  457. package/dist/graph-schema/fixtures.d.ts +23 -0
  458. package/dist/graph-schema/fixtures.d.ts.map +1 -0
  459. package/dist/graph-schema/fixtures.js +246 -0
  460. package/dist/graph-schema/generate.d.ts +15 -0
  461. package/dist/graph-schema/generate.d.ts.map +1 -0
  462. package/dist/graph-schema/generate.js +267 -0
  463. package/dist/graph-schema/graph.schema.json +1387 -0
  464. package/dist/health.schema.json +2 -1
  465. package/dist/identity.d.ts.map +1 -1
  466. package/dist/identity.js +2 -0
  467. package/dist/index.d.ts +2 -0
  468. package/dist/index.d.ts.map +1 -1
  469. package/dist/index.js +4 -0
  470. package/dist/instance-nodes.d.ts +159 -0
  471. package/dist/instance-nodes.d.ts.map +1 -0
  472. package/dist/instance-nodes.js +231 -0
  473. package/dist/lexicon.d.ts +178 -6
  474. package/dist/lexicon.d.ts.map +1 -1
  475. package/dist/lifecycle/adoption-file.d.ts +80 -0
  476. package/dist/lifecycle/adoption-file.d.ts.map +1 -0
  477. package/dist/lifecycle/adoption-file.js +122 -0
  478. package/dist/lifecycle/cloud-index.d.ts +186 -0
  479. package/dist/lifecycle/cloud-index.d.ts.map +1 -0
  480. package/dist/lifecycle/cloud-index.js +617 -0
  481. package/dist/lifecycle/derive-edges.d.ts +59 -0
  482. package/dist/lifecycle/derive-edges.d.ts.map +1 -0
  483. package/dist/lifecycle/derive-edges.js +126 -0
  484. package/dist/lifecycle/gate-applied.d.ts +6 -0
  485. package/dist/lifecycle/gate-applied.d.ts.map +1 -1
  486. package/dist/lifecycle/gate-ledger.d.ts +29 -0
  487. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  488. package/dist/lifecycle/gate-ledger.js +11 -1
  489. package/dist/lifecycle/gate-pending-by-plan.d.ts +75 -0
  490. package/dist/lifecycle/gate-pending-by-plan.d.ts.map +1 -0
  491. package/dist/lifecycle/gate-pending-by-plan.js +96 -0
  492. package/dist/lifecycle/gated-request-digest.d.ts +28 -0
  493. package/dist/lifecycle/gated-request-digest.d.ts.map +1 -0
  494. package/dist/lifecycle/gated-request-digest.js +35 -0
  495. package/dist/lifecycle/gated-request.d.ts +126 -0
  496. package/dist/lifecycle/gated-request.d.ts.map +1 -0
  497. package/dist/lifecycle/gated-request.js +205 -0
  498. package/dist/lifecycle/git.d.ts +10 -9
  499. package/dist/lifecycle/git.d.ts.map +1 -1
  500. package/dist/lifecycle/git.js +7 -1
  501. package/dist/lifecycle/identity-match.d.ts +148 -0
  502. package/dist/lifecycle/identity-match.d.ts.map +1 -0
  503. package/dist/lifecycle/identity-match.js +152 -0
  504. package/dist/lifecycle/index-diff.d.ts +264 -0
  505. package/dist/lifecycle/index-diff.d.ts.map +1 -0
  506. package/dist/lifecycle/index-diff.js +326 -0
  507. package/dist/lifecycle/index-document.d.ts +130 -0
  508. package/dist/lifecycle/index-document.d.ts.map +1 -0
  509. package/dist/lifecycle/index-document.js +188 -0
  510. package/dist/lifecycle/index-drift.d.ts +121 -0
  511. package/dist/lifecycle/index-drift.d.ts.map +1 -0
  512. package/dist/lifecycle/index-drift.js +178 -0
  513. package/dist/lifecycle/index-import.d.ts +171 -0
  514. package/dist/lifecycle/index-import.d.ts.map +1 -0
  515. package/dist/lifecycle/index-import.js +512 -0
  516. package/dist/lifecycle/index-join.d.ts +129 -0
  517. package/dist/lifecycle/index-join.d.ts.map +1 -0
  518. package/dist/lifecycle/index-join.js +248 -0
  519. package/dist/lifecycle/index.d.ts +4 -0
  520. package/dist/lifecycle/index.d.ts.map +1 -1
  521. package/dist/lifecycle/index.js +4 -0
  522. package/dist/lifecycle/ledger-read.d.ts.map +1 -1
  523. package/dist/lifecycle/ledger-read.js +7 -3
  524. package/dist/lifecycle/lock-rows.d.ts +76 -0
  525. package/dist/lifecycle/lock-rows.d.ts.map +1 -0
  526. package/dist/lifecycle/lock-rows.js +140 -0
  527. package/dist/lifecycle/observation-baseline.d.ts +61 -21
  528. package/dist/lifecycle/observation-baseline.d.ts.map +1 -1
  529. package/dist/lifecycle/observation-baseline.js +144 -19
  530. package/dist/lifecycle/observe.d.ts.map +1 -1
  531. package/dist/lifecycle/observe.js +6 -1
  532. package/dist/lifecycle/query.d.ts +94 -6
  533. package/dist/lifecycle/query.d.ts.map +1 -1
  534. package/dist/lifecycle/query.js +182 -9
  535. package/dist/lifecycle/release-catalog-site.d.ts +66 -0
  536. package/dist/lifecycle/release-catalog-site.d.ts.map +1 -0
  537. package/dist/lifecycle/release-catalog-site.js +232 -0
  538. package/dist/lifecycle/release-catalog.d.ts +201 -0
  539. package/dist/lifecycle/release-catalog.d.ts.map +1 -0
  540. package/dist/lifecycle/release-catalog.js +198 -0
  541. package/dist/lifecycle/release-changelog.d.ts +41 -0
  542. package/dist/lifecycle/release-changelog.d.ts.map +1 -0
  543. package/dist/lifecycle/release-changelog.js +38 -0
  544. package/dist/lifecycle/release-cut.d.ts +1 -0
  545. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  546. package/dist/lifecycle/release-cut.js +1 -1
  547. package/dist/lifecycle/release-ledger.d.ts +16 -0
  548. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  549. package/dist/lifecycle/release-ledger.js +10 -0
  550. package/dist/lifecycle/release-publish.d.ts +43 -22
  551. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  552. package/dist/lifecycle/release-read.d.ts.map +1 -1
  553. package/dist/lifecycle/release-read.js +3 -0
  554. package/dist/lifecycle/release-status.d.ts +86 -0
  555. package/dist/lifecycle/release-status.d.ts.map +1 -0
  556. package/dist/lifecycle/release-status.js +136 -0
  557. package/dist/lifecycle/replay.d.ts +10 -3
  558. package/dist/lifecycle/replay.d.ts.map +1 -1
  559. package/dist/lifecycle/replay.js +10 -6
  560. package/dist/lifecycle/resource-lock.d.ts +120 -0
  561. package/dist/lifecycle/resource-lock.d.ts.map +1 -0
  562. package/dist/lifecycle/resource-lock.js +317 -0
  563. package/dist/lifecycle/retention.d.ts.map +1 -1
  564. package/dist/lifecycle/retention.js +3 -0
  565. package/dist/lifecycle/run-ledger.d.ts.map +1 -1
  566. package/dist/lifecycle/run-ledger.js +9 -1
  567. package/dist/lifecycle/scenario.d.ts +4 -3
  568. package/dist/lifecycle/scenario.d.ts.map +1 -1
  569. package/dist/lifecycle/snapshot-store-fake.d.ts +9 -0
  570. package/dist/lifecycle/snapshot-store-fake.d.ts.map +1 -0
  571. package/dist/lifecycle/snapshot-store-fake.js +21 -0
  572. package/dist/lifecycle/snapshot-store-s3.d.ts +135 -0
  573. package/dist/lifecycle/snapshot-store-s3.d.ts.map +1 -0
  574. package/dist/lifecycle/snapshot-store-s3.js +219 -0
  575. package/dist/lifecycle/snapshot-store.d.ts +170 -0
  576. package/dist/lifecycle/snapshot-store.d.ts.map +1 -0
  577. package/dist/lifecycle/snapshot-store.js +831 -0
  578. package/dist/lifecycle/snapshot.d.ts +11 -0
  579. package/dist/lifecycle/snapshot.d.ts.map +1 -1
  580. package/dist/lifecycle/snapshot.js +18 -5
  581. package/dist/lifecycle/target-lock.d.ts +15 -0
  582. package/dist/lifecycle/target-lock.d.ts.map +1 -1
  583. package/dist/lifecycle/target-lock.js +25 -10
  584. package/dist/lifecycle/type-listing.d.ts +148 -0
  585. package/dist/lifecycle/type-listing.d.ts.map +1 -0
  586. package/dist/lifecycle/type-listing.js +166 -0
  587. package/dist/lint/component-checks.d.ts +15 -1
  588. package/dist/lint/component-checks.d.ts.map +1 -1
  589. package/dist/lint/component-checks.js +1 -0
  590. package/dist/lint/presets/relaxed.json +2 -1
  591. package/dist/lint/presets/strict.json +2 -1
  592. package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.d.ts +4 -0
  593. package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.d.ts.map +1 -0
  594. package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.js +13 -0
  595. package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.d.ts +4 -0
  596. package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.d.ts.map +1 -0
  597. package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.js +8 -0
  598. package/dist/lint/rules/comp/comp008-applies-signal-only-root.d.ts +33 -0
  599. package/dist/lint/rules/comp/comp008-applies-signal-only-root.d.ts.map +1 -0
  600. package/dist/lint/rules/comp/comp008-applies-signal-only-root.js +123 -0
  601. package/dist/lint/rules/comp/index.d.ts +2 -1
  602. package/dist/lint/rules/comp/index.d.ts.map +1 -1
  603. package/dist/lint/rules/comp/index.js +4 -1
  604. package/dist/mcp/types.d.ts +7 -0
  605. package/dist/mcp/types.d.ts.map +1 -1
  606. package/dist/notify-product.d.ts +43 -0
  607. package/dist/notify-product.d.ts.map +1 -0
  608. package/dist/notify-product.js +58 -0
  609. package/dist/notify-relay.d.ts +197 -0
  610. package/dist/notify-relay.d.ts.map +1 -0
  611. package/dist/notify-relay.js +321 -0
  612. package/dist/notify.d.ts +44 -4
  613. package/dist/notify.d.ts.map +1 -1
  614. package/dist/notify.js +77 -14
  615. package/dist/object-store/azure-blob.d.ts +129 -0
  616. package/dist/object-store/azure-blob.d.ts.map +1 -0
  617. package/dist/object-store/azure-blob.js +341 -0
  618. package/dist/object-store/common.d.ts +108 -0
  619. package/dist/object-store/common.d.ts.map +1 -0
  620. package/dist/object-store/common.js +80 -0
  621. package/dist/object-store/errors.d.ts +28 -0
  622. package/dist/object-store/errors.d.ts.map +1 -0
  623. package/dist/object-store/errors.js +21 -0
  624. package/dist/object-store/from-env.d.ts +18 -0
  625. package/dist/object-store/from-env.d.ts.map +1 -0
  626. package/dist/object-store/from-env.js +22 -0
  627. package/dist/object-store/gcs.d.ts +106 -0
  628. package/dist/object-store/gcs.d.ts.map +1 -0
  629. package/dist/object-store/gcs.js +393 -0
  630. package/dist/object-store/index.d.ts +9 -0
  631. package/dist/object-store/index.d.ts.map +1 -0
  632. package/dist/object-store/index.js +8 -0
  633. package/dist/object-store/s3.d.ts +146 -0
  634. package/dist/object-store/s3.d.ts.map +1 -0
  635. package/dist/object-store/s3.js +306 -0
  636. package/dist/observation.d.ts +19 -2
  637. package/dist/observation.d.ts.map +1 -1
  638. package/dist/observation.js +18 -1
  639. package/dist/op/activities/activity-contracts.d.ts +1 -1
  640. package/dist/op/activities/activity-contracts.js +1 -1
  641. package/dist/op/activities/change-set.d.ts +6 -4
  642. package/dist/op/activities/change-set.d.ts.map +1 -1
  643. package/dist/op/activities/change-set.js +4 -2
  644. package/dist/op/activities/converge.d.ts.map +1 -1
  645. package/dist/op/activities/converge.js +2 -1
  646. package/dist/op/activities/index.d.ts +1 -1
  647. package/dist/op/activities/index.d.ts.map +1 -1
  648. package/dist/op/activities/index.js +1 -1
  649. package/dist/op/activities/review-agent.d.ts +55 -2
  650. package/dist/op/activities/review-agent.d.ts.map +1 -1
  651. package/dist/op/activities/review-agent.js +65 -5
  652. package/dist/op/activity-failure.d.ts +27 -0
  653. package/dist/op/activity-failure.d.ts.map +1 -1
  654. package/dist/op/activity-failure.js +31 -0
  655. package/dist/op/gate.d.ts +29 -1
  656. package/dist/op/gate.d.ts.map +1 -1
  657. package/dist/op/gate.js +59 -23
  658. package/dist/op/generate-pipeline.d.ts.map +1 -1
  659. package/dist/op/generate-pipeline.js +7 -1
  660. package/dist/op/index.d.ts +14 -2
  661. package/dist/op/index.d.ts.map +1 -1
  662. package/dist/op/index.js +8 -2
  663. package/dist/op/local-executor.d.ts +5 -1
  664. package/dist/op/local-executor.d.ts.map +1 -1
  665. package/dist/op/local-executor.js +22 -8
  666. package/dist/op/op-waves-after-plan.d.ts +137 -0
  667. package/dist/op/op-waves-after-plan.d.ts.map +1 -0
  668. package/dist/op/op-waves-after-plan.js +163 -0
  669. package/dist/op/op-waves-capability-spec.d.ts +55 -0
  670. package/dist/op/op-waves-capability-spec.d.ts.map +1 -0
  671. package/dist/op/op-waves-capability-spec.js +94 -0
  672. package/dist/op/op-waves-capability.d.ts +197 -0
  673. package/dist/op/op-waves-capability.d.ts.map +1 -0
  674. package/dist/op/op-waves-capability.js +311 -0
  675. package/dist/op/op-waves-events.d.ts +54 -0
  676. package/dist/op/op-waves-events.d.ts.map +1 -0
  677. package/dist/op/op-waves-events.js +122 -0
  678. package/dist/op/op-waves-notify.d.ts +7 -1
  679. package/dist/op/op-waves-notify.d.ts.map +1 -1
  680. package/dist/op/op-waves-notify.js +35 -16
  681. package/dist/op/op-waves-release-port.d.ts +18 -0
  682. package/dist/op/op-waves-release-port.d.ts.map +1 -0
  683. package/dist/op/op-waves-release-port.js +61 -0
  684. package/dist/op/op-waves-release.d.ts +92 -0
  685. package/dist/op/op-waves-release.d.ts.map +1 -0
  686. package/dist/op/op-waves-release.js +97 -0
  687. package/dist/op/op-waves-run.d.ts +175 -4
  688. package/dist/op/op-waves-run.d.ts.map +1 -1
  689. package/dist/op/op-waves-run.js +981 -41
  690. package/dist/op/op-waves-stand-down.d.ts +60 -0
  691. package/dist/op/op-waves-stand-down.d.ts.map +1 -0
  692. package/dist/op/op-waves-stand-down.js +97 -0
  693. package/dist/op/op-waves.d.ts +152 -8
  694. package/dist/op/op-waves.d.ts.map +1 -1
  695. package/dist/op/op-waves.js +161 -17
  696. package/dist/op/runtime.d.ts +91 -0
  697. package/dist/op/runtime.d.ts.map +1 -1
  698. package/dist/op/runtime.js +19 -0
  699. package/dist/op/stage-hooks.d.ts +45 -7
  700. package/dist/op/stage-hooks.d.ts.map +1 -1
  701. package/dist/op/stage-hooks.js +61 -3
  702. package/dist/op/steward-beside.d.ts.map +1 -1
  703. package/dist/op/steward-beside.js +2 -1
  704. package/dist/op/types.d.ts +2 -2
  705. package/dist/op/types.d.ts.map +1 -1
  706. package/dist/op/types.js +3 -2
  707. package/dist/otlp-metrics.d.ts +38 -0
  708. package/dist/otlp-metrics.d.ts.map +1 -0
  709. package/dist/otlp-metrics.js +82 -0
  710. package/dist/otlp.d.ts +249 -0
  711. package/dist/otlp.d.ts.map +1 -0
  712. package/dist/otlp.js +426 -0
  713. package/dist/override-gate.d.ts.map +1 -1
  714. package/dist/override-gate.js +5 -0
  715. package/dist/policy-packs.d.ts +69 -0
  716. package/dist/policy-packs.d.ts.map +1 -0
  717. package/dist/policy-packs.js +205 -0
  718. package/dist/policy-source.d.ts +51 -0
  719. package/dist/policy-source.d.ts.map +1 -0
  720. package/dist/policy-source.js +103 -0
  721. package/dist/pr-forge.d.ts +40 -0
  722. package/dist/pr-forge.d.ts.map +1 -1
  723. package/dist/pr-forge.js +92 -0
  724. package/dist/pr-loop.d.ts +205 -12
  725. package/dist/pr-loop.d.ts.map +1 -1
  726. package/dist/pr-loop.js +330 -41
  727. package/dist/pr-post.d.ts +16 -0
  728. package/dist/pr-post.d.ts.map +1 -1
  729. package/dist/pr-post.js +26 -1
  730. package/dist/pr-report-url.d.ts +32 -4
  731. package/dist/pr-report-url.d.ts.map +1 -1
  732. package/dist/pr-report-url.js +46 -5
  733. package/dist/pr-requires.d.ts +13 -2
  734. package/dist/pr-requires.d.ts.map +1 -1
  735. package/dist/pr-requires.js +14 -0
  736. package/dist/pulumi-urn.d.ts +101 -0
  737. package/dist/pulumi-urn.d.ts.map +1 -0
  738. package/dist/pulumi-urn.js +131 -0
  739. package/dist/release-floors.d.ts +23 -0
  740. package/dist/release-floors.d.ts.map +1 -0
  741. package/dist/release-floors.js +22 -0
  742. package/dist/run-event.d.ts +26 -1
  743. package/dist/run-event.d.ts.map +1 -1
  744. package/dist/run-event.js +4 -1
  745. package/dist/sensitive-key.d.ts +23 -0
  746. package/dist/sensitive-key.d.ts.map +1 -0
  747. package/dist/sensitive-key.js +31 -0
  748. package/dist/sorted-json.d.ts +10 -0
  749. package/dist/sorted-json.d.ts.map +1 -0
  750. package/dist/sorted-json.js +14 -0
  751. package/dist/terraform/credentials.d.ts +59 -0
  752. package/dist/terraform/credentials.d.ts.map +1 -0
  753. package/dist/terraform/credentials.js +149 -0
  754. package/dist/utils.d.ts +1 -4
  755. package/dist/utils.d.ts.map +1 -1
  756. package/dist/utils.js +1 -9
  757. package/dist/wave-runtime.d.ts +1 -1
  758. package/dist/wave-runtime.js +2 -2
  759. package/dist/wave-runtime.mjs +390 -285
  760. package/dist/workspace/adoption-report.d.ts +53 -0
  761. package/dist/workspace/adoption-report.d.ts.map +1 -0
  762. package/dist/workspace/adoption-report.js +76 -0
  763. package/dist/workspace/capabilities-contract.d.ts +7 -0
  764. package/dist/workspace/capabilities-contract.d.ts.map +1 -1
  765. package/dist/workspace/capabilities-contract.js +2 -1
  766. package/dist/workspace/capabilities.schema.json +98 -0
  767. package/dist/workspace/change-set.schema.json +42 -3
  768. package/dist/workspace/chant-migrations/chud-lexicon-exit.d.ts.map +1 -1
  769. package/dist/workspace/chant-migrations/chud-lexicon-exit.js +4 -1
  770. package/dist/workspace/ci-cloud-identity.d.ts +13 -1
  771. package/dist/workspace/ci-cloud-identity.d.ts.map +1 -1
  772. package/dist/workspace/ci-cloud-identity.js +30 -1
  773. package/dist/workspace/ci-lock-grain.d.ts +12 -0
  774. package/dist/workspace/ci-lock-grain.d.ts.map +1 -0
  775. package/dist/workspace/ci-lock-grain.js +27 -0
  776. package/dist/workspace/ci-run.d.ts +2 -1
  777. package/dist/workspace/ci-run.d.ts.map +1 -1
  778. package/dist/workspace/ci-run.js +6 -3
  779. package/dist/workspace/compose-graph.d.ts +10 -1
  780. package/dist/workspace/compose-graph.d.ts.map +1 -1
  781. package/dist/workspace/compose-graph.js +6 -1
  782. package/dist/workspace/conformance/index.d.ts +1 -1
  783. package/dist/workspace/conformance/index.d.ts.map +1 -1
  784. package/dist/workspace/conformance/index.js +6 -1
  785. package/dist/workspace/declaration.d.ts +16 -4
  786. package/dist/workspace/declaration.d.ts.map +1 -1
  787. package/dist/workspace/declaration.js +5 -2
  788. package/dist/workspace/declaration.schema.json +27 -3
  789. package/dist/workspace/drift-cli.d.ts +81 -0
  790. package/dist/workspace/drift-cli.d.ts.map +1 -0
  791. package/dist/workspace/drift-cli.js +322 -0
  792. package/dist/workspace/drift.schema.json +672 -0
  793. package/dist/workspace/exit-cli.d.ts +1 -1
  794. package/dist/workspace/exit-cli.d.ts.map +1 -1
  795. package/dist/workspace/exit-cli.js +2 -1
  796. package/dist/workspace/graph-cli.d.ts +2 -0
  797. package/dist/workspace/graph-cli.d.ts.map +1 -1
  798. package/dist/workspace/graph-cli.js +3 -0
  799. package/dist/workspace/graph.schema.json +72 -0
  800. package/dist/workspace/import-fetch.d.ts +4 -2
  801. package/dist/workspace/import-fetch.d.ts.map +1 -1
  802. package/dist/workspace/import-fetch.js +4 -2
  803. package/dist/workspace/import-init.d.ts.map +1 -1
  804. package/dist/workspace/import-init.js +4 -2
  805. package/dist/workspace/init.d.ts +5 -1
  806. package/dist/workspace/init.d.ts.map +1 -1
  807. package/dist/workspace/init.js +55 -9
  808. package/dist/workspace/ledger.schema.json +7 -3
  809. package/dist/workspace/lineage-upgrade-cli.d.ts +1 -1
  810. package/dist/workspace/lineage-upgrade-cli.d.ts.map +1 -1
  811. package/dist/workspace/lineage-upgrade-cli.js +2 -1
  812. package/dist/workspace/nested-graph.d.ts.map +1 -1
  813. package/dist/workspace/nested-graph.js +2 -0
  814. package/dist/workspace/pr-report.schema.json +125 -5
  815. package/dist/workspace/promote-waves.d.ts +112 -0
  816. package/dist/workspace/promote-waves.d.ts.map +1 -0
  817. package/dist/workspace/promote-waves.js +290 -0
  818. package/dist/workspace/promote.d.ts +85 -3
  819. package/dist/workspace/promote.d.ts.map +1 -1
  820. package/dist/workspace/promote.js +349 -62
  821. package/dist/workspace/reason-codes.d.ts +12 -0
  822. package/dist/workspace/reason-codes.d.ts.map +1 -1
  823. package/dist/workspace/reason-codes.js +14 -0
  824. package/dist/workspace/records-cli.d.ts +2 -2
  825. package/dist/workspace/records-cli.d.ts.map +1 -1
  826. package/dist/workspace/records-cli.js +3 -2
  827. package/dist/workspace/release-catalog.schema.json +277 -0
  828. package/dist/workspace/run-event.schema.json +18 -1
  829. package/dist/workspace/search-contract.d.ts +3 -3
  830. package/dist/workspace/search-contract.d.ts.map +1 -1
  831. package/dist/workspace/search-contract.js +2 -0
  832. package/dist/workspace/search.schema.json +103 -5
  833. package/dist/workspace/work-cli.d.ts +3 -1
  834. package/dist/workspace/work-cli.d.ts.map +1 -1
  835. package/dist/workspace/work-cli.js +7 -2
  836. package/dist/workspace/workspace-run.d.ts.map +1 -1
  837. package/dist/workspace/workspace-run.js +2 -1
  838. package/package.json +34 -1
  839. package/src/__fixtures__/drift-record/README.md +58 -0
  840. package/src/__fixtures__/drift-record/choudoufu-cone.ndjson +4 -0
  841. package/src/__fixtures__/drift-record/choudoufu-resource.ndjson +3 -0
  842. package/src/__fixtures__/drift-record/component-status-ledger.json +65 -0
  843. package/src/__fixtures__/drift-record/component-status.json +91 -0
  844. package/src/__fixtures__/drift-record/deep-diff.json +259 -0
  845. package/src/__fixtures__/drift-record/lifecycle-diff-live.json +825 -0
  846. package/src/__fixtures__/drift-record/live-diff.json +125 -0
  847. package/src/__fixtures__/estate-ledger.ts +101 -0
  848. package/src/__fixtures__/oidc-emulator.ts +31 -2
  849. package/src/__fixtures__/product-words.ts +44 -0
  850. package/src/__golden__/wave-loop/op-by-apply-after-fails.json +10 -2
  851. package/src/__golden__/wave-loop/op-by-apply-hold.json +20 -4
  852. package/src/__golden__/wave-loop/op-by-apply-ignored.json +10 -2
  853. package/src/__golden__/wave-loop/op-by-apply-pass.json +10 -2
  854. package/src/__golden__/wave-loop/op-by-apply-skip.json +10 -2
  855. package/src/__golden__/wave-loop/op-discover-rest-stops.json +22 -6
  856. package/src/__golden__/wave-loop/op-discover-rest.json +44 -12
  857. package/src/__golden__/wave-loop/op-discover-wide.json +12 -3
  858. package/src/__golden__/wave-loop/op-held-on.json +28 -7
  859. package/src/__golden__/wave-loop/op-hooks-apply-fails.json +22 -6
  860. package/src/__golden__/wave-loop/op-hooks-fail-after-apply.json +22 -6
  861. package/src/__golden__/wave-loop/op-hooks-fail-before-apply.json +4 -2
  862. package/src/__golden__/wave-loop/op-hooks-held.json +26 -8
  863. package/src/__golden__/wave-loop/op-hooks-hold-before-apply.json +18 -4
  864. package/src/__golden__/wave-loop/op-hooks-pass.json +22 -6
  865. package/src/__golden__/wave-loop/op-hooks-share.json +20 -7
  866. package/src/__golden__/wave-loop/op-outcome-held.json +12 -3
  867. package/src/__golden__/wave-loop/op-outcome-replan-approved.json +16 -5
  868. package/src/__golden__/wave-loop/op-outcome-replan-forever.json +48 -21
  869. package/src/__golden__/wave-loop/op-outcome-replan.json +16 -5
  870. package/src/__golden__/wave-loop/op-outcome-stood-down.json +12 -3
  871. package/src/__golden__/wave-loop/op-outcome-unreadable.json +12 -3
  872. package/src/__golden__/wave-loop/op-overridden.json +28 -7
  873. package/src/__golden__/wave-loop/op-per-run.json +20 -4
  874. package/src/__golden__/wave-loop/op-point.json +18 -4
  875. package/src/__golden__/wave-loop/op-pr-review.json +10 -2
  876. package/src/__golden__/wave-loop/op-spend-change-only.json +10 -2
  877. package/src/__golden__/wave-loop/op-spend.json +10 -2
  878. package/src/__golden__/wave-loop/op-wave-commands.json +56 -13
  879. package/src/__golden__/wave-loop/op-wide.json +20 -4
  880. package/src/audit/discover.e2e.test.ts +14 -0
  881. package/src/audit/discover.ts +3 -1
  882. package/src/behaviour.ts +1 -1
  883. package/src/bucket-check/azure.ts +307 -0
  884. package/src/bucket-check/bucket-check.test.ts +210 -0
  885. package/src/bucket-check/fixtures/azure.json +153 -0
  886. package/src/bucket-check/fixtures/gcs.json +148 -0
  887. package/src/bucket-check/fixtures/s3.json +277 -0
  888. package/src/bucket-check/gcs.ts +257 -0
  889. package/src/bucket-check/index.ts +61 -0
  890. package/src/bucket-check/s3.ts +433 -0
  891. package/src/bucket-check/types.ts +75 -0
  892. package/src/bucket-check/wire.ts +50 -0
  893. package/src/bucket-check.ts +5 -0
  894. package/src/capabilities/templates.json +145 -0
  895. package/src/capabilities/templates.test.ts +211 -0
  896. package/src/capabilities/templates.ts +203 -0
  897. package/src/cdk/advise.test.ts +1 -1
  898. package/src/change-set-bundle.test.ts +82 -0
  899. package/src/change-set-graph.ts +80 -9
  900. package/src/change-set.test.ts +24 -0
  901. package/src/change-set.ts +76 -14
  902. package/src/ci-agent.test.ts +348 -0
  903. package/src/ci-agent.ts +1026 -0
  904. package/src/ci-control.ts +174 -0
  905. package/src/ci-estate/delivery.ts +433 -0
  906. package/src/ci-estate/overdue.ts +81 -0
  907. package/src/ci-estate/page.ts +343 -0
  908. package/src/ci-estate/rows.ts +251 -0
  909. package/src/ci-estate.test.ts +281 -0
  910. package/src/ci-estate.ts +176 -0
  911. package/src/ci-handover.ts +67 -16
  912. package/src/ci-identity-database.test.ts +55 -0
  913. package/src/ci-identity-pulumi.test.ts +163 -0
  914. package/src/ci-identity-targets.test.ts +29 -2
  915. package/src/ci-identity.ts +134 -26
  916. package/src/ci-product-words.test.ts +101 -0
  917. package/src/ci-product-words.ts +536 -0
  918. package/src/ci-product.ts +174 -0
  919. package/src/ci-shared-reads.test.ts +145 -0
  920. package/src/cli/commands/audit.test.ts +1 -1
  921. package/src/cli/commands/audit.ts +3 -2
  922. package/src/cli/commands/carve.test.ts +1 -1
  923. package/src/cli/commands/carve.ts +2 -2
  924. package/src/cli/commands/import-index.test.ts +117 -0
  925. package/src/cli/commands/import-index.ts +265 -0
  926. package/src/cli/commands/init.ts +3 -1
  927. package/src/cli/commands/lint.ts +4 -2
  928. package/src/cli/component-wave-args.test.ts +16 -0
  929. package/src/cli/handlers/agent.ts +126 -0
  930. package/src/cli/handlers/approve-confirm.test.ts +276 -0
  931. package/src/cli/handlers/approve-confirm.ts +200 -0
  932. package/src/cli/handlers/approve.ts +18 -1
  933. package/src/cli/handlers/build.test.ts +7 -0
  934. package/src/cli/handlers/build.ts +44 -1
  935. package/src/cli/handlers/ci-check.ts +33 -0
  936. package/src/cli/handlers/ci-forge-check.ts +91 -0
  937. package/src/cli/handlers/components.test.ts +9 -0
  938. package/src/cli/handlers/components.ts +12 -2
  939. package/src/cli/handlers/fan-out.test.ts +10 -10
  940. package/src/cli/handlers/fan-out.ts +22 -3
  941. package/src/cli/handlers/gate-pending.ts +46 -0
  942. package/src/cli/handlers/graph.test.ts +42 -0
  943. package/src/cli/handlers/graph.ts +26 -4
  944. package/src/cli/handlers/index-cloud.ts +32 -0
  945. package/src/cli/handlers/index-diff.test.ts +68 -0
  946. package/src/cli/handlers/index-diff.ts +146 -0
  947. package/src/cli/handlers/init.ts +1 -0
  948. package/src/cli/handlers/ledger-root-member.test.ts +161 -0
  949. package/src/cli/handlers/ledger.ts +1 -1
  950. package/src/cli/handlers/lifecycle-drift.ts +73 -0
  951. package/src/cli/handlers/lifecycle.test.ts +33 -11
  952. package/src/cli/handlers/lifecycle.ts +205 -30
  953. package/src/cli/handlers/lock.test.ts +29 -2
  954. package/src/cli/handlers/lock.ts +66 -6
  955. package/src/cli/handlers/misc.ts +73 -0
  956. package/src/cli/handlers/notify-relay.ts +130 -0
  957. package/src/cli/handlers/pr-before-merge.test.ts +2 -1
  958. package/src/cli/handlers/pr-deploy-inputs.test.ts +7 -7
  959. package/src/cli/handlers/pr-env.ts +48 -11
  960. package/src/cli/handlers/pr-plan-targets.test.ts +155 -0
  961. package/src/cli/handlers/pr-waves-blocked.test.ts +42 -2
  962. package/src/cli/handlers/pr-waves.test.ts +8 -2
  963. package/src/cli/handlers/pr.test.ts +8 -8
  964. package/src/cli/handlers/pr.ts +669 -207
  965. package/src/cli/handlers/promote.test.ts +69 -5
  966. package/src/cli/handlers/promote.ts +103 -8
  967. package/src/cli/handlers/query.ts +27 -4
  968. package/src/cli/handlers/release.ts +2 -0
  969. package/src/cli/handlers/run-components-exit.test.ts +7 -7
  970. package/src/cli/handlers/run-declared-reads-cli.test.ts +187 -0
  971. package/src/cli/handlers/run-groups-cli.test.ts +229 -0
  972. package/src/cli/handlers/run-wave.ts +65 -1
  973. package/src/cli/handlers/run.test.ts +6 -4
  974. package/src/cli/handlers/run.ts +86 -1
  975. package/src/cli/handlers/scenario.test.ts +13 -0
  976. package/src/cli/handlers/scenario.ts +8 -7
  977. package/src/cli/handlers/search-index.test.ts +255 -0
  978. package/src/cli/handlers/search-json.test.ts +1 -1
  979. package/src/cli/handlers/search-ownership.test.ts +194 -0
  980. package/src/cli/handlers/search.ts +271 -38
  981. package/src/cli/handlers/serve.ts +10 -1
  982. package/src/cli/main.test.ts +7 -0
  983. package/src/cli/main.ts +182 -14
  984. package/src/cli/mcp/ledger-tools.ts +126 -0
  985. package/src/cli/mcp/lifecycle-tools.ts +3 -2
  986. package/src/cli/mcp/product-tools.test.ts +123 -0
  987. package/src/cli/mcp/product-tools.ts +129 -0
  988. package/src/cli/mcp/read-only.test.ts +134 -0
  989. package/src/cli/mcp/read-only.ts +68 -0
  990. package/src/cli/mcp/report-tools.ts +135 -0
  991. package/src/cli/mcp/resource-handlers.ts +4 -3
  992. package/src/cli/mcp/server.test.ts +5 -4
  993. package/src/cli/mcp/server.ts +90 -16
  994. package/src/cli/mcp/workspace-tools.ts +1 -1
  995. package/src/cli/mcp-config.ts +8 -3
  996. package/src/cli/parse-args.ts +82 -4
  997. package/src/cli/registry.ts +54 -1
  998. package/src/cloud-lister/aws.test.ts +202 -0
  999. package/src/cloud-lister/aws.ts +226 -0
  1000. package/src/cloud-lister/azure.test.ts +132 -0
  1001. package/src/cloud-lister/azure.ts +142 -0
  1002. package/src/cloud-lister/common.ts +115 -0
  1003. package/src/cloud-lister/credentials.ts +110 -0
  1004. package/src/cloud-lister/fakes.ts +66 -0
  1005. package/src/cloud-lister/gcp.test.ts +121 -0
  1006. package/src/cloud-lister/gcp.ts +159 -0
  1007. package/src/cloud-lister/guard.test.ts +198 -0
  1008. package/src/cloud-lister/guard.ts +111 -0
  1009. package/src/cloud-lister/ids.ts +54 -0
  1010. package/src/cloud-lister/index.ts +134 -0
  1011. package/src/cloud-lister/kubernetes.test.ts +160 -0
  1012. package/src/cloud-lister/kubernetes.ts +284 -0
  1013. package/src/cloud-lister/markers.ts +74 -0
  1014. package/src/cloud-lister/mask.ts +77 -0
  1015. package/src/cloud-lister/shape.test.ts +81 -0
  1016. package/src/cloud-lister/sigv4.ts +127 -0
  1017. package/src/cloud-lister/transport.ts +118 -0
  1018. package/src/cloud-lister/types.ts +135 -0
  1019. package/src/components/adoption.test.ts +140 -0
  1020. package/src/components/adoption.ts +141 -0
  1021. package/src/components/apply-lease.ts +49 -0
  1022. package/src/components/capability-plugin-loader.ts +4 -0
  1023. package/src/components/capability-plugin.ts +10 -0
  1024. package/src/components/capability.ts +359 -6
  1025. package/src/components/check-hooks.test.ts +66 -0
  1026. package/src/components/check-hooks.ts +252 -0
  1027. package/src/components/ci-services.test.ts +51 -0
  1028. package/src/components/ci-services.ts +83 -0
  1029. package/src/components/cli-support.ts +92 -15
  1030. package/src/components/declared-reads.test.ts +103 -0
  1031. package/src/components/declared-reads.ts +134 -0
  1032. package/src/components/deploy-units.ts +4 -0
  1033. package/src/components/driver.test.ts +3 -3
  1034. package/src/components/driver.ts +127 -9
  1035. package/src/components/fan-out-run.ts +163 -33
  1036. package/src/components/fan-out-support.ts +10 -1
  1037. package/src/components/fan-out.ts +30 -0
  1038. package/src/components/groups.test.ts +320 -0
  1039. package/src/components/groups.ts +895 -0
  1040. package/src/components/index.ts +42 -0
  1041. package/src/components/plan-shape-conformance.ts +130 -0
  1042. package/src/components/pr-comment-preview.test.ts +54 -0
  1043. package/src/components/pr-env-ledger.test.ts +9 -0
  1044. package/src/components/pr-env-ledger.ts +43 -0
  1045. package/src/components/pr-env-ports.ts +29 -4
  1046. package/src/components/pr-env-run-bundle.test.ts +10 -0
  1047. package/src/components/pr-env-run.test.ts +19 -0
  1048. package/src/components/pr-env-run.ts +12 -2
  1049. package/src/components/pr-environment.test.ts +29 -0
  1050. package/src/components/pr-environment.ts +39 -7
  1051. package/src/components/pr-pipeline.test.ts +15 -0
  1052. package/src/components/pr-pipeline.ts +274 -9
  1053. package/src/components/pr-policy.ts +45 -7
  1054. package/src/components/pr-run.test.ts +516 -3
  1055. package/src/components/pr-run.ts +350 -44
  1056. package/src/components/pr-targets.test.ts +35 -0
  1057. package/src/components/pr-targets.ts +45 -0
  1058. package/src/components/product-pipeline.test.ts +200 -0
  1059. package/src/components/product-pipeline.ts +341 -0
  1060. package/src/components/promote-rounds.ts +25 -2
  1061. package/src/components/promote.ts +64 -5
  1062. package/src/components/registry.test.ts +1 -1
  1063. package/src/components/release-compile.ts +87 -1
  1064. package/src/components/release-gate.ts +115 -30
  1065. package/src/components/release-groups.test.ts +362 -0
  1066. package/src/components/release-promote.ts +65 -1
  1067. package/src/components/repo-lock.ts +52 -0
  1068. package/src/components/row-lease.test.ts +490 -0
  1069. package/src/components/row-lease.ts +167 -0
  1070. package/src/components/run-groups.ts +113 -0
  1071. package/src/components/starter-plugin.ts +6 -0
  1072. package/src/components/verbs/index.ts +1 -0
  1073. package/src/components/verbs/member-outputs.test.ts +205 -0
  1074. package/src/components/verbs/member-outputs.ts +308 -0
  1075. package/src/components/wave-plan-policy.test.ts +19 -0
  1076. package/src/components/wave-plan.ts +78 -4
  1077. package/src/config.ts +44 -0
  1078. package/src/control/__fixtures__/consumers/apps/consumers.json +15 -0
  1079. package/src/control/__fixtures__/consumers/infra/consumers.json +23 -0
  1080. package/src/control/applied.test.ts +148 -0
  1081. package/src/control/applied.ts +191 -0
  1082. package/src/control/consumers.test.ts +129 -0
  1083. package/src/control/consumers.ts +192 -0
  1084. package/src/control/control.test.ts +302 -0
  1085. package/src/control/dispatch.ts +699 -0
  1086. package/src/control/edges.test.ts +112 -0
  1087. package/src/control/edges.ts +164 -0
  1088. package/src/control/note-checkout.test.ts +91 -0
  1089. package/src/control/reconcile.ts +250 -0
  1090. package/src/control/records.ts +395 -0
  1091. package/src/deep-observation.ts +5 -23
  1092. package/src/discovery/sandbox/bundle.ts +25 -1
  1093. package/src/drift-record.test.ts +596 -0
  1094. package/src/drift-record.ts +1206 -0
  1095. package/src/engine-facts.guard.test.ts +111 -0
  1096. package/src/engine-facts.test.ts +177 -0
  1097. package/src/engine-facts.ts +153 -0
  1098. package/src/exit-codes.test.ts +31 -0
  1099. package/src/exit-codes.ts +55 -0
  1100. package/src/forge-check/check.ts +155 -0
  1101. package/src/forge-check/contract.ts +215 -0
  1102. package/src/forge-check/forge-check.test.ts +427 -0
  1103. package/src/forge-check/forge.ts +318 -0
  1104. package/src/forge-check/index.ts +43 -0
  1105. package/src/forge-check/pulumi.ts +192 -0
  1106. package/src/forge-check/read-only.ts +56 -0
  1107. package/src/forge-check/trust.ts +527 -0
  1108. package/src/forge-check/types.ts +78 -0
  1109. package/src/forge-check.ts +5 -0
  1110. package/src/gate-decision-bundle.test.ts +13 -0
  1111. package/src/gate-decision.ts +3 -0
  1112. package/src/gate-policy.ts +92 -3
  1113. package/src/gated-waves-bundle.test.ts +1 -0
  1114. package/src/graph-ir-live.test.ts +92 -0
  1115. package/src/graph-ir.ts +317 -7
  1116. package/src/graph-refs.ts +416 -0
  1117. package/src/graph-schema/fixtures/adopt.json +15 -0
  1118. package/src/graph-schema/fixtures/choudoufu.engine-graph.json +169 -0
  1119. package/src/graph-schema/fixtures/index.json +68 -0
  1120. package/src/graph-schema/fixtures/plunge.engine-graph.json +158 -0
  1121. package/src/graph-schema/fixtures.ts +267 -0
  1122. package/src/graph-schema/generate.ts +263 -0
  1123. package/src/graph-schema/graph-schema.test.ts +153 -0
  1124. package/src/graph-schema/graph.schema.json +1387 -0
  1125. package/src/health.schema.json +2 -1
  1126. package/src/identity.ts +2 -0
  1127. package/src/index.ts +4 -0
  1128. package/src/instance-nodes.ts +288 -0
  1129. package/src/lexicon.ts +171 -6
  1130. package/src/lifecycle/__fixtures__/index-diff/20261026T120000Z-aaaaaaaaaaaa.json +149 -0
  1131. package/src/lifecycle/__fixtures__/index-diff/20261026T130000Z-bbbbbbbbbbbb.json +127 -0
  1132. package/src/lifecycle/adoption-file.test.ts +100 -0
  1133. package/src/lifecycle/adoption-file.ts +153 -0
  1134. package/src/lifecycle/cloud-index.test.ts +516 -0
  1135. package/src/lifecycle/cloud-index.ts +735 -0
  1136. package/src/lifecycle/control-entries-ledger.test.ts +70 -0
  1137. package/src/lifecycle/derive-edges.test.ts +193 -0
  1138. package/src/lifecycle/derive-edges.ts +182 -0
  1139. package/src/lifecycle/gate-applied.ts +6 -0
  1140. package/src/lifecycle/gate-ledger.ts +36 -1
  1141. package/src/lifecycle/gate-pending-by-plan.test.ts +69 -0
  1142. package/src/lifecycle/gate-pending-by-plan.ts +133 -0
  1143. package/src/lifecycle/gated-request-digest.ts +49 -0
  1144. package/src/lifecycle/gated-request-ledger.test.ts +53 -0
  1145. package/src/lifecycle/gated-request.ts +280 -0
  1146. package/src/lifecycle/git.ts +10 -4
  1147. package/src/lifecycle/identity-match.test.ts +308 -0
  1148. package/src/lifecycle/identity-match.ts +276 -0
  1149. package/src/lifecycle/index-diff.test.ts +198 -0
  1150. package/src/lifecycle/index-diff.ts +475 -0
  1151. package/src/lifecycle/index-document.test.ts +64 -0
  1152. package/src/lifecycle/index-document.ts +298 -0
  1153. package/src/lifecycle/index-drift.test.ts +191 -0
  1154. package/src/lifecycle/index-drift.ts +304 -0
  1155. package/src/lifecycle/index-import.test.ts +269 -0
  1156. package/src/lifecycle/index-import.ts +654 -0
  1157. package/src/lifecycle/index-join.test.ts +250 -0
  1158. package/src/lifecycle/index-join.ts +304 -0
  1159. package/src/lifecycle/index-store-load-bearing.test.ts +187 -0
  1160. package/src/lifecycle/index.ts +4 -0
  1161. package/src/lifecycle/ledger-read.ts +7 -3
  1162. package/src/lifecycle/lock-rows.test.ts +109 -0
  1163. package/src/lifecycle/lock-rows.ts +167 -0
  1164. package/src/lifecycle/member-ledger.test.ts +25 -7
  1165. package/src/lifecycle/observation-baseline.test.ts +72 -1
  1166. package/src/lifecycle/observation-baseline.ts +190 -27
  1167. package/src/lifecycle/observe.ts +6 -1
  1168. package/src/lifecycle/publish-target-context.test.ts +108 -0
  1169. package/src/lifecycle/query.test.ts +68 -1
  1170. package/src/lifecycle/query.ts +208 -13
  1171. package/src/lifecycle/release-catalog-site.test.ts +142 -0
  1172. package/src/lifecycle/release-catalog-site.ts +291 -0
  1173. package/src/lifecycle/release-catalog.test.ts +193 -0
  1174. package/src/lifecycle/release-catalog.ts +353 -0
  1175. package/src/lifecycle/release-changelog.test.ts +70 -0
  1176. package/src/lifecycle/release-changelog.ts +71 -0
  1177. package/src/lifecycle/release-cut.ts +2 -2
  1178. package/src/lifecycle/release-ledger.ts +20 -0
  1179. package/src/lifecycle/release-publish.ts +45 -22
  1180. package/src/lifecycle/release-read.ts +2 -0
  1181. package/src/lifecycle/release-status.test.ts +186 -0
  1182. package/src/lifecycle/release-status.ts +176 -0
  1183. package/src/lifecycle/replay.test.ts +9 -5
  1184. package/src/lifecycle/replay.ts +9 -5
  1185. package/src/lifecycle/resource-lock.test.ts +175 -0
  1186. package/src/lifecycle/resource-lock.ts +354 -0
  1187. package/src/lifecycle/retention.ts +2 -0
  1188. package/src/lifecycle/run-ledger.ts +7 -1
  1189. package/src/lifecycle/scenario.ts +4 -3
  1190. package/src/lifecycle/snapshot-store-fake.ts +29 -0
  1191. package/src/lifecycle/snapshot-store-s3.ts +280 -0
  1192. package/src/lifecycle/snapshot-store.test.ts +385 -0
  1193. package/src/lifecycle/snapshot-store.ts +980 -0
  1194. package/src/lifecycle/snapshot.test.ts +13 -0
  1195. package/src/lifecycle/snapshot.ts +23 -6
  1196. package/src/lifecycle/target-lock.ts +24 -9
  1197. package/src/lifecycle/type-listing.test.ts +166 -0
  1198. package/src/lifecycle/type-listing.ts +309 -0
  1199. package/src/lint/component-checks.ts +17 -1
  1200. package/src/lint/config.test.ts +3 -0
  1201. package/src/lint/presets/relaxed.json +2 -1
  1202. package/src/lint/presets/strict.json +2 -1
  1203. package/src/lint/rules/__fixtures__/comp/comp008/fail/dns.component.ts +15 -0
  1204. package/src/lint/rules/__fixtures__/comp/comp008/pass/dns.component.ts +10 -0
  1205. package/src/lint/rules/comp/comp.test.ts +2 -1
  1206. package/src/lint/rules/comp/comp008-applies-signal-only-root.ts +121 -0
  1207. package/src/lint/rules/comp/comp008.test.ts +77 -0
  1208. package/src/lint/rules/comp/index.ts +4 -1
  1209. package/src/mcp/types.ts +7 -0
  1210. package/src/notify-product.ts +76 -0
  1211. package/src/notify-relay.test.ts +213 -0
  1212. package/src/notify-relay.ts +407 -0
  1213. package/src/notify.ts +95 -14
  1214. package/src/object-store/azure-blob.ts +374 -0
  1215. package/src/object-store/common.ts +133 -0
  1216. package/src/object-store/errors.ts +26 -0
  1217. package/src/object-store/from-env.ts +36 -0
  1218. package/src/object-store/gcs.ts +436 -0
  1219. package/src/object-store/index.ts +8 -0
  1220. package/src/object-store/object-store.test.ts +130 -0
  1221. package/src/object-store/s3.ts +350 -0
  1222. package/src/observation-edges.test.ts +33 -0
  1223. package/src/observation.ts +36 -1
  1224. package/src/op/activities/activity-contracts.ts +1 -1
  1225. package/src/op/activities/change-set.ts +8 -5
  1226. package/src/op/activities/converge.ts +2 -1
  1227. package/src/op/activities/index.ts +1 -1
  1228. package/src/op/activities/review-agent.open.test.ts +78 -0
  1229. package/src/op/activities/review-agent.test.ts +13 -0
  1230. package/src/op/activities/review-agent.ts +89 -5
  1231. package/src/op/activity-failure.ts +36 -0
  1232. package/src/op/gate.ts +81 -22
  1233. package/src/op/generate-pipeline.ts +7 -1
  1234. package/src/op/index.ts +23 -1
  1235. package/src/op/local-executor.test.ts +80 -0
  1236. package/src/op/local-executor.ts +27 -9
  1237. package/src/op/op-waves-after-plan.test.ts +276 -0
  1238. package/src/op/op-waves-after-plan.ts +238 -0
  1239. package/src/op/op-waves-capability-spec.ts +113 -0
  1240. package/src/op/op-waves-capability.test.ts +217 -0
  1241. package/src/op/op-waves-capability.ts +370 -0
  1242. package/src/op/op-waves-events.ts +135 -0
  1243. package/src/op/op-waves-notify-words.test.ts +149 -0
  1244. package/src/op/op-waves-notify.ts +41 -16
  1245. package/src/op/op-waves-pull-request.test.ts +142 -0
  1246. package/src/op/op-waves-release-port.ts +64 -0
  1247. package/src/op/op-waves-release.test.ts +209 -0
  1248. package/src/op/op-waves-release.ts +133 -0
  1249. package/src/op/op-waves-run-record.test.ts +32 -0
  1250. package/src/op/op-waves-run.ts +1142 -49
  1251. package/src/op/op-waves-stand-down.test.ts +240 -0
  1252. package/src/op/op-waves-stand-down.ts +108 -0
  1253. package/src/op/op-waves-trace.test.ts +205 -0
  1254. package/src/op/op-waves.test.ts +112 -0
  1255. package/src/op/op-waves.ts +261 -20
  1256. package/src/op/runtime.ts +104 -0
  1257. package/src/op/stage-hooks-hold-record.test.ts +41 -0
  1258. package/src/op/stage-hooks.ts +91 -12
  1259. package/src/op/steward-beside.ts +2 -1
  1260. package/src/op/types.ts +3 -2
  1261. package/src/otlp-metrics.ts +96 -0
  1262. package/src/otlp.test.ts +243 -0
  1263. package/src/otlp.ts +544 -0
  1264. package/src/override-gate-bundle.test.ts +2 -0
  1265. package/src/override-gate.ts +4 -0
  1266. package/src/policy-packs.ts +230 -0
  1267. package/src/policy-source.test.ts +256 -0
  1268. package/src/policy-source.ts +112 -0
  1269. package/src/pr-forge.ts +123 -0
  1270. package/src/pr-loop-bundle.test.ts +9 -2
  1271. package/src/pr-loop-words.test.ts +155 -0
  1272. package/src/pr-loop.test.ts +43 -0
  1273. package/src/pr-loop.ts +478 -50
  1274. package/src/pr-post.ts +32 -1
  1275. package/src/pr-report-url.ts +62 -6
  1276. package/src/pr-requires.test.ts +37 -1
  1277. package/src/pr-requires.ts +16 -2
  1278. package/src/product-subpaths-plain-node.e2e.test.ts +211 -0
  1279. package/src/pulumi-urn.ts +151 -0
  1280. package/src/release-floors.ts +22 -0
  1281. package/src/run-event.ts +29 -1
  1282. package/src/sensitive-key.ts +34 -0
  1283. package/src/sorted-json.ts +17 -0
  1284. package/src/stage-hooks-bundle.test.ts +8 -0
  1285. package/src/terraform/credentials.test.ts +77 -0
  1286. package/src/terraform/credentials.ts +162 -0
  1287. package/src/utils.ts +2 -11
  1288. package/src/wave-loop-golden.test.ts +2 -1
  1289. package/src/wave-runtime.ts +2 -2
  1290. package/src/workspace/adoption-report.test.ts +61 -0
  1291. package/src/workspace/adoption-report.ts +103 -0
  1292. package/src/workspace/capabilities-contract.test.ts +4 -0
  1293. package/src/workspace/capabilities-contract.ts +9 -1
  1294. package/src/workspace/capabilities.schema.json +98 -0
  1295. package/src/workspace/change-set.schema.json +42 -3
  1296. package/src/workspace/chant-migrations/chud-lexicon-exit.ts +4 -1
  1297. package/src/workspace/ci-cloud-identity.ts +31 -1
  1298. package/src/workspace/ci-lock-grain.test.ts +31 -0
  1299. package/src/workspace/ci-lock-grain.ts +30 -0
  1300. package/src/workspace/ci-report-url.test.ts +1 -1
  1301. package/src/workspace/ci-run.test.ts +1 -1
  1302. package/src/workspace/ci-run.ts +6 -3
  1303. package/src/workspace/compose-graph.test.ts +12 -0
  1304. package/src/workspace/compose-graph.ts +12 -1
  1305. package/src/workspace/conformance/conformance.e2e.test.ts +2 -1
  1306. package/src/workspace/conformance/index.ts +6 -1
  1307. package/src/workspace/declaration.schema.json +27 -3
  1308. package/src/workspace/declaration.test.ts +1 -1
  1309. package/src/workspace/declaration.ts +26 -10
  1310. package/src/workspace/drift-cli.test.ts +65 -0
  1311. package/src/workspace/drift-cli.ts +370 -0
  1312. package/src/workspace/drift.schema.json +672 -0
  1313. package/src/workspace/exit-cli.ts +2 -1
  1314. package/src/workspace/graph-cli.ts +5 -0
  1315. package/src/workspace/graph.schema.json +72 -0
  1316. package/src/workspace/import-fetch.ts +4 -2
  1317. package/src/workspace/import-init.ts +4 -2
  1318. package/src/workspace/init.test.ts +38 -1
  1319. package/src/workspace/init.ts +50 -8
  1320. package/src/workspace/intent-gaps.test.ts +18 -2
  1321. package/src/workspace/ledger.schema.json +7 -3
  1322. package/src/workspace/lineage-upgrade-cli.ts +2 -1
  1323. package/src/workspace/nested-graph.ts +1 -0
  1324. package/src/workspace/pr-report.schema.json +125 -5
  1325. package/src/workspace/promote-waves.test.ts +296 -0
  1326. package/src/workspace/promote-waves.ts +340 -0
  1327. package/src/workspace/promote.test.ts +158 -4
  1328. package/src/workspace/promote.ts +400 -58
  1329. package/src/workspace/reason-codes.test.ts +4 -1
  1330. package/src/workspace/reason-codes.ts +14 -0
  1331. package/src/workspace/records-cli.ts +3 -2
  1332. package/src/workspace/release-catalog.schema.json +277 -0
  1333. package/src/workspace/run-event.schema.json +18 -1
  1334. package/src/workspace/search-contract.ts +2 -0
  1335. package/src/workspace/search.schema.json +103 -5
  1336. package/src/workspace/work-cli.ts +8 -2
  1337. package/src/workspace/workspace-run.ts +2 -1
@@ -50,8 +50,11 @@
50
50
  */
51
51
 
52
52
  import { execFileSync, spawnSync } from "node:child_process";
53
+ import { createHash } from "node:crypto";
53
54
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
54
55
  import { dirname, isAbsolute, join, posix } from "node:path";
56
+ import { CHANT_EXIT } from "../exit-codes";
57
+ import type { ResolvedGatePolicySource } from "../policy-source";
55
58
  import {
56
59
  decideWaveGate,
57
60
  runWaveLoop,
@@ -74,16 +77,47 @@ import {
74
77
  type WaveMemberOutcome,
75
78
  } from "../wave-blocked";
76
79
  import { approveCommand, evaluateGate, gitGateLedgerPort, type GateCheck, type GateDigestMismatch, type GateLedgerPort } from "./gate";
77
- import type { GateAnswerRef, PendingGateRecord } from "../lifecycle/gate-ledger";
80
+ import type { GateAnswerRef, PendingGateInput, PendingGateRecord } from "../lifecycle/gate-ledger";
78
81
  import type { GatePointAsker } from "../point-decision";
79
82
  import type { WaitingPoint } from "./steward-points";
80
- import { isApprovalSpent, type AppliedGateRecord } from "../lifecycle/gate-applied";
83
+ import { isApprovalSpent, type AppliedGateRecord, type FinishedGateRecord } from "../lifecycle/gate-applied";
81
84
  import { samePlanDigest } from "../lifecycle/plan-digest";
82
85
  import { isLifecycleLocalNote } from "../lifecycle/local-note";
83
86
  import type { HeadPlans, MergedReview, ReviewSource } from "./gate-review";
84
87
  import type { TrustPolicy } from "../workspace/trust/policy";
85
88
  import type { GateSigners } from "../lifecycle/gate-seal";
86
89
  import { ciRunIdFromEnv } from "./gate-run-locator";
90
+ import { appendRunRecord, DEFAULT_RUN_ENV } from "../lifecycle/run-ledger";
91
+ import { pushLifecycleReport } from "../lifecycle/git";
92
+ import { resolveCiJob } from "../lifecycle/release-ledger";
93
+ import type { OpRunPolicyRow, OpRunRecordInput, OpRunStepRecord, OpRunWave, OpRunWavePlan, OpRunWaveTarget } from "./runtime";
94
+ import { foldPolicyRows, opWaveAfterPlanProblems, runOpWaveAfterPlanHooks, type OpWaveAfterPlanHook, type OpWaveAfterPlanRun } from "./op-waves-after-plan";
95
+ import { activeOtlp, RunEventTrace, type CapabilityTraceFacts, type OtlpExporter } from "../otlp";
96
+ import { joinRunEventSinks, resolveRunEventRun, type RunEventSink } from "../run-event-stream";
97
+ import { OpWaveRunEvents } from "./op-waves-events";
98
+ import type { ChangeSetDocument, ChangeSetPart } from "../change-set";
99
+ import type { CapabilityRegistry } from "../components/capability";
100
+ import type { RunEventResource } from "../run-event";
101
+ import { opWaveReleaseNames, type OpWaveReleaseOutcome, type OpWaveReleasePort, type OpWaveReleaseRequest } from "./op-waves-release";
102
+ import { gitOpWaveReleasePort } from "./op-waves-release-port";
103
+ import type { LockGrain } from "../lifecycle/lock-rows";
104
+ import type { LockLiveness } from "../lifecycle/resource-lock";
105
+ import type { GatePolicyExec } from "../gate-policy";
106
+ import { gitOpWaveNewerCommit, opWaveStandDownReason, tipAppliesTargets, type OpWaveNewerCommitPort } from "./op-waves-stand-down";
107
+ import {
108
+ applyOpWaveStep,
109
+ opWaveCosts,
110
+ opWaveCostVerdict,
111
+ opWaveHoldsAt,
112
+ opWaveHoldsProblems,
113
+ opWavePolicyVerdicts,
114
+ opWaveRegistry,
115
+ opWaveStepChangeSet,
116
+ planJsonOf,
117
+ planOpWaveStep,
118
+ type OpWaveHolds,
119
+ type OpWaveStepPlan,
120
+ } from "./op-waves-capability";
87
121
  import {
88
122
  changeInvolvement, quorumProblems, quorumRuleLine, quorumRulesFor, quorumWaiting, recordedReviewApprovals, ruleNeedsProof, samePrincipal, trustQuorumJudge,
89
123
  type GateQuorumJudge, type GateQuorumRule, type GateQuorumRuleProgress, type QuorumJudgement,
@@ -123,8 +157,11 @@ import {
123
157
  OP_WAVE_PENDING_RESERVED,
124
158
  opWaveArgv,
125
159
  pendingFields,
160
+ holdFinishedPath,
161
+ readHoldFinished,
126
162
  readHoldRequest,
127
163
  runHookList,
164
+ runHookListAsync,
128
165
  runStageHooks,
129
166
  runStageHooksAsync,
130
167
  spawnExec,
@@ -132,6 +169,7 @@ import {
132
169
  type HookPlace,
133
170
  type OpWaveAsyncExec,
134
171
  type OpWaveExec,
172
+ type OpWaveHoldFinished,
135
173
  type OpWaveHoldRequest,
136
174
  type OpWaveHookOutcome,
137
175
  type OpWaveHookRun,
@@ -142,7 +180,7 @@ import {
142
180
  } from "./stage-hooks";
143
181
 
144
182
  export { OP_WAVE_PENDING_RESERVED, opWaveArgv, runStageHooks, runStageHooksAsync, spawnExecAsync };
145
- export type { OpWaveAsyncExec, OpWaveExec, OpWaveHoldRequest, OpWaveHookOutcome, OpWaveHookRun, RunStageHooksAsyncOptions, RunStageHooksOptions, StageHooksRun };
183
+ export type { OpWaveAsyncExec, OpWaveExec, OpWaveHoldFinished, OpWaveHoldRequest, OpWaveHookOutcome, OpWaveHookRun, RunStageHooksAsyncOptions, RunStageHooksOptions, StageHooksRun };
146
184
 
147
185
  /** What a run's plan command writes to `{plan}`. */
148
186
  export interface OpWavePlanFile {
@@ -164,6 +202,8 @@ export interface OpWavePlanFile {
164
202
  * approve` holds it. `@intentius/chant/gate-policy` gives the rules.
165
203
  */
166
204
  held?: { rules: string[]; reason?: string };
205
+ /** The run's change-set part (#4545), which a `holds.policy` hold runs the policy over. A `step` writes it itself. */
206
+ changeSet?: ChangeSetPart;
167
207
  }
168
208
 
169
209
  /** What a wave-level plan command writes to `{plans}` (#3762): one plan per run, by target. The array alone is read too. */
@@ -190,6 +230,15 @@ export interface OpWavePlansFile {
190
230
  members?: WaveMember[];
191
231
  /** On a discovering wave (#3821): how many waves the product found, which a `rest` wave walks to. */
192
232
  waves?: number;
233
+ /**
234
+ * The change-set document the product composed for the wave's plans
235
+ * (#4551, `composeChangeSet`). chant stores it under its digest in
236
+ * `_change-sets/` before the wave's pending fact, which cites it as
237
+ * `changeSet`, so the plans an approval was asked for stay readable. A
238
+ * document whose content does not hash to its digest is logged and left
239
+ * out; it never blocks the gate.
240
+ */
241
+ changeSet?: ChangeSetDocument;
193
242
  }
194
243
 
195
244
  /** What chant writes to `{runs}` for a wave-level command or a hook (#3762). */
@@ -244,8 +293,16 @@ export interface OpWaveDecision {
244
293
  */
245
294
  status: "approved" | "not-required" | "waiting" | "refused";
246
295
  approvedBy?: string;
247
- /** How the approval arrived: a resolution on the ledger, the merged pull request's review (#3684), or a decision point's answer (#3836). */
248
- via?: "ledger" | "pr-review" | "point";
296
+ /**
297
+ * How the approval arrived: a resolution on the ledger, the merged pull
298
+ * request's review (#3684), a decision point's answer (#3836), or the pull
299
+ * request's approval covering the wave's plans (#4550).
300
+ */
301
+ via?: "ledger" | "pr-review" | "point" | "pull-request";
302
+ /** Under `pull-request` (#4550): the gate the pull request's approval is recorded at, read at base. */
303
+ pullRequestGate?: string;
304
+ /** Under `pull-request`: the approved change set that covered the wave, or why none did. */
305
+ coveredBy?: { digest?: string; reason?: string };
249
306
  /**
250
307
  * The decision point the gate asks, as read at base (#3836), and what it
251
308
  * said: the open `question` while the wave waits, the `answer` once it is
@@ -287,6 +344,8 @@ export interface OpWaveDecision {
287
344
  digestOver?: "changing";
288
345
  /** The fields the plans file added to the pending fact (#3821). */
289
346
  pending?: Record<string, unknown>;
347
+ /** The digest of the change set the plans file gave, stored in `_change-sets/` and cited by the pending fact (#4551). */
348
+ changeSet?: string;
290
349
  /** The pending fact carries `neverOverMcp`, set by the spec here or at base (#3821). */
291
350
  neverOverMcp?: true;
292
351
  /** While waiting (#3821): the pending fact that stands for the digest, this run's own when `recorded`. */
@@ -322,6 +381,13 @@ export interface OpWaveDecision {
322
381
  extras?: WaveMember[];
323
382
  /** On a discovering wave (#3821): how many waves the plan command found. */
324
383
  discovered?: { waves?: number };
384
+ /**
385
+ * `ci.policy.source` as `holds.policy` fetched it (#4613): the shared
386
+ * repository, its ref and the commit the ref named, so the decision names
387
+ * the rules its runs were judged by. Absent when the rules came from the
388
+ * workspace at base, or no policy ran.
389
+ */
390
+ ciPolicySource?: ResolvedGatePolicySource;
325
391
  }
326
392
 
327
393
  /**
@@ -511,6 +577,12 @@ export interface OpWaveBaseRules {
511
577
  reviewLedger?: string;
512
578
  /** `approvals.involved` at base (#4333). */
513
579
  involved?: OpWavesInvolved;
580
+ /** `holds` at base (#4545): the policy and cost holds the wave runs over its plans. */
581
+ holds?: OpWaveHolds;
582
+ /** Set when `holds` at base cannot be read: none runs, and the wave waits for a person. */
583
+ holdsRefused?: string;
584
+ /** `approvals.pullRequest.gate` at base (#4550): the pull request's gate a `pull-request` wave takes its approval from. */
585
+ pullRequestGate?: string;
514
586
  }
515
587
 
516
588
  const noHooks = (): Record<OpWaveHookMoment, OpWaveHook[]> =>
@@ -543,7 +615,7 @@ export function readOpWavePolicy(
543
615
  const spend = (spec as { approvals?: { spend?: unknown } }).approvals?.spend === true;
544
616
  const neverOverMcp = (spec as { neverOverMcp?: unknown }).neverOverMcp === true;
545
617
  // #3836: the gate's decision point, the spec's for a wave the base does not have yet.
546
- const asks = { ...pointAtBase(spec, name, `${specFile} at ${sha.slice(0, 12)}`), ...quorumAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`) };
618
+ const asks = { ...pointAtBase(spec, name, `${specFile} at ${sha.slice(0, 12)}`), ...quorumAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`), ...holdsAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`), ...pullRequestGateAtBase(spec) };
547
619
  const wave = spec.waves.find((w) => w.name === name);
548
620
  if (!wave) return { ...absent, spend, neverOverMcp, ...asks };
549
621
  const policy = wave.gate ?? "always";
@@ -562,6 +634,12 @@ export function readOpWavePolicy(
562
634
  return rules;
563
635
  }
564
636
 
637
+ /** `approvals.pullRequest.gate` at base (#4550), when it names a gate. */
638
+ function pullRequestGateAtBase(spec: OpWavesSpec): Pick<OpWaveBaseRules, "pullRequestGate"> {
639
+ const gate = (spec as { approvals?: { pullRequest?: { gate?: unknown } } }).approvals?.pullRequest?.gate;
640
+ return typeof gate === "string" && OP_LEDGER_NAME.test(gate) ? { pullRequestGate: gate } : {};
641
+ }
642
+
565
643
  /** The approval rules at base (#4290), or why they cannot be read. A spec at base with none has none. */
566
644
  function quorumAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "quorum" | "quorumRefused" | "reviewLedger" | "involved"> {
567
645
  const a = (spec as { approvals?: { quorum?: unknown; reviewLedger?: unknown; involved?: unknown } }).approvals;
@@ -583,6 +661,15 @@ function quorumAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "
583
661
  return (raw as GateQuorumRule[]).length > 0 ? { quorum: raw as GateQuorumRule[], ...extra } : {};
584
662
  }
585
663
 
664
+ /** The holds at base (#4545), or why they cannot be read. */
665
+ function holdsAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "holds" | "holdsRefused"> {
666
+ const raw = (spec as { holds?: unknown }).holds;
667
+ if (raw === undefined) return {};
668
+ const problems = opWaveHoldsProblems(raw);
669
+ if (problems.length > 0) return { holdsRefused: `the holds in ${where} cannot be read (${problems.join("; ")})` };
670
+ return { holds: structuredClone(raw as OpWaveHolds) };
671
+ }
672
+
586
673
  /** The point wave `name` asks at base (#3836), or why it cannot be asked. */
587
674
  function pointAtBase(spec: OpWavesSpec, name: string, where: string): Pick<OpWaveBaseRules, "point" | "pointRefused"> {
588
675
  const raw = spec.waves.find((w) => w.name === name)?.point ?? spec.point;
@@ -635,6 +722,12 @@ export interface RunOpWaveOptions {
635
722
  reviews?: ReviewSource;
636
723
  /** The plans recorded for a pull request's head. Default: read from `chant/lifecycle`. */
637
724
  headPlans?: (name: string, head: string) => Promise<HeadPlans | null>;
725
+ /**
726
+ * The change set stored under a digest, for a `pull-request` gate (#4550):
727
+ * the one the pull request's approval names. Default: `_change-sets/` on
728
+ * the local `chant/lifecycle`.
729
+ */
730
+ changeSets?: (digest: string) => Promise<ChangeSetDocument | undefined>;
638
731
  /** The signers policy at base, for a `sealed` gate. Default: read from the base commit. */
639
732
  trust?: (base: string) => TrustPolicy;
640
733
  /** The signers at base, for a sealed override of a policy denial (#3821). Default: `gateSignersAt` from `@intentius/chant/gate-decision`. */
@@ -649,6 +742,96 @@ export interface RunOpWaveOptions {
649
742
  outcomeDir?: string;
650
743
  /** The commits after base up to the applied head, for `Requested-by:` trailers (#4333). Default: `git log`. */
651
744
  commits?: (base: string, head: string) => { sha: string; message: string }[];
745
+ /**
746
+ * Where the job's run record goes (#4551): one record per job, on every
747
+ * way it ends. Default {@link gitOpWaveRunPort} over `cwd` when `gates` is
748
+ * not given; a caller that passes its own `gates` port passes this too, or
749
+ * the job records no run.
750
+ */
751
+ runs?: OpWaveRunPort;
752
+ /**
753
+ * Where the release records of the runs a `step` applied go (#4615), so
754
+ * `chant components rollback` reads them. Default
755
+ * {@link gitOpWaveReleasePort} over `cwd` when `gates` is not given, as
756
+ * `runs` defaults; `false` writes none. See `./op-waves-release.ts`.
757
+ */
758
+ releases?: OpWaveReleasePort | false;
759
+ /**
760
+ * The capabilities a spec's `step` plans and applies through (#4545).
761
+ * Default: the project's at `cwd`, as `chant run --components` builds it.
762
+ * A product that runs chant in process passes its own.
763
+ */
764
+ capabilities?: CapabilityRegistry;
765
+ /** How a hold's policy engine and cost estimator run (#4545). Default: spawned in `cwd`. */
766
+ holdExec?: GatePolicyExec;
767
+ /**
768
+ * How the `planWave` and `applyWave` commands run (#4588), when the caller
769
+ * runs them itself, such as `pr-apply --wave-gate` running the component
770
+ * plan-wave and apply-wave steps in its own process. Default: `exec`.
771
+ */
772
+ waveExec?: OpWaveAsyncExec;
773
+ /**
774
+ * The lock grain a `step`'s runs take (#4552). Default: `ci.lockGrain` of
775
+ * the member holding `cwd`, read from the declaration at the wave's base,
776
+ * else each run's lexicon default.
777
+ */
778
+ lockGrain?: LockGrain;
779
+ /**
780
+ * The gate whose rows file (`_locks/rows/<gate>.json`, #4552) a `step`'s
781
+ * runs lease on the resource grain. Default `pr-apply`, the pull-request
782
+ * loop's, so an apply on merge and an apply before merge read one file; a
783
+ * pipeline whose loop names another gate passes it.
784
+ */
785
+ lockGate?: string;
786
+ /** Whether a run holding rows still runs (#4552). Default: the forge's answer, with the lease's age. */
787
+ lockLiveness?: LockLiveness;
788
+ /** Overrides the spec's `standDown` (#4581). */
789
+ standDown?: boolean;
790
+ /** How the job finds a newer commit on its branch (#4581). Default: fetch the branch from `origin` ({@link gitOpWaveNewerCommit}). */
791
+ newerCommit?: OpWaveNewerCommitPort;
792
+ /**
793
+ * Where the job's run events go (#4555), on the run-event contract: a
794
+ * phase `wave-<k>` per wave and a step per run target, settled as the
795
+ * run record says. `chant run wave --events-json` passes its stream.
796
+ */
797
+ events?: RunEventSink;
798
+ /**
799
+ * The OTLP exporter the job's trace goes through (#4555). Default: the
800
+ * process's ({@link activeOtlp}), which is off unless the environment
801
+ * names an endpoint. `false` sends none.
802
+ */
803
+ otlp?: OtlpExporter | false;
804
+ /**
805
+ * After-plan hooks in the job's own process (#4614): each is called once
806
+ * per planned run, in order, after the wave's holds and before the set
807
+ * digest and the gate, with the run's plan digest, `{plan}` and
808
+ * `{planJson}`. Its policy rows deny or hold the run, and its rows and
809
+ * files go on the run record. See `./op-waves-after-plan.ts`.
810
+ */
811
+ afterPlan?: OpWaveAfterPlanHook | readonly OpWaveAfterPlanHook[];
812
+ /**
813
+ * How the spec's command hooks run (#4614), when they call back into the
814
+ * caller's own process: a product that runs the wave in process and serves
815
+ * its hooks from that process passes an exec that lets the event loop run
816
+ * while a hook does. Default: `exec`, which waits with `spawnSync`.
817
+ */
818
+ hookExec?: OpWaveAsyncExec;
819
+ }
820
+
821
+ /** Where an op wave job's run record goes (#4551). */
822
+ export interface OpWaveRunPort {
823
+ append(record: OpRunRecordInput): Promise<{ pushWarning?: string } | void>;
824
+ }
825
+
826
+ /** The run ledger on `chant/lifecycle` (#4551): `appendRunRecord`, then a push. Honours `--no-record` through the git layer. */
827
+ export function gitOpWaveRunPort(opts?: { cwd?: string }): OpWaveRunPort {
828
+ return {
829
+ async append(record) {
830
+ await appendRunRecord(record, opts);
831
+ const { pushWarning } = await pushLifecycleReport(opts);
832
+ return pushWarning ? { pushWarning } : {};
833
+ },
834
+ };
652
835
  }
653
836
 
654
837
  export interface RunOpWaveResult {
@@ -665,6 +848,8 @@ export interface RunOpWaveResult {
665
848
  outcome?: OpWaveApplyOutcome;
666
849
  /** Set when the apply asked to plan again (#3821); {@link runOpWave} does, so a caller sees it only on a pass that gave up. */
667
850
  replan?: { reason?: string };
851
+ /** The newer commit on the branch the apply stood down for (#4581), with `outcome` `stood-down` and exit 6. */
852
+ supersededBy?: { branch: string; commit: string };
668
853
  /** The waves a `rest` wave's job ran (#3821), in order, with how each ended. */
669
854
  rest?: Array<{ wave: number; exitCode: number; digest?: string }>;
670
855
  decision?: OpWaveDecision;
@@ -680,6 +865,10 @@ export interface RunOpWaveResult {
680
865
  blocked?: Record<string, string>;
681
866
  /** The hooks that ran (#3762). */
682
867
  hooks: OpWaveHookOutcome[];
868
+ /** Each target the job applied or tried to (#4555): when, how long, and what its capability knew. */
869
+ targets?: Record<string, OpRunWaveTarget>;
870
+ /** Each planned run with policy rows or an after-plan hook's files (#4614), as the run record's `wave.plans`. */
871
+ plans?: Record<string, OpRunWavePlan>;
683
872
  }
684
873
 
685
874
  /** What one wave job works with. */
@@ -694,6 +883,10 @@ interface WaveContext {
694
883
  options: RunOpWaveOptions;
695
884
  /** How another gate a hook holds the wave on is decided (#3821): the approval mode and base the wave's rules were read at, and whether pending facts carry neverOverMcp. */
696
885
  gateRule: { approval: GateApprovalSource; base: string; neverOverMcp: boolean };
886
+ /** With a `step` (#4545): each run's plan through it, by target, which its apply hands back. */
887
+ steps?: Map<string, OpWaveStepPlan>;
888
+ /** The plans file's change set (#4551), which a `pull-request` gate checks the pull request's approval against (#4550). */
889
+ changeSetDoc?: ChangeSetDocument;
697
890
  }
698
891
 
699
892
  function planRun(opts: { spec: OpWavesSpec; wave: number; cwd: string; exec: OpWaveExec }, waveName: string, run: OpWaveRun): OpWaveMember {
@@ -767,13 +960,22 @@ function writeRunsFile(
767
960
  * for all of them (#3762). A wave plan is written out as each run's plan file
768
961
  * too, so a per-run `apply` or hook reads `{plan}` either way.
769
962
  */
770
- function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec }, runs: readonly OpWaveRun[], discover = false): PlannedRuns {
963
+ async function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec; waveExec?: OpWaveAsyncExec }, runs: readonly OpWaveRun[], discover = false): Promise<PlannedRuns> {
771
964
  const { spec, k, wave, cwd, exec } = at;
772
- if (!spec.planWave) return { members: runs.map((run) => planRun({ spec, wave: k, cwd, exec }, wave.name, run)) };
965
+ if (!spec.planWave) {
966
+ const members = runs.map((run) => planRun({ spec, wave: k, cwd, exec }, wave.name, run));
967
+ // #4545: a plan file's `changeSet` part, which a policy hold reads.
968
+ const parts = new Map(runs.flatMap((run) => {
969
+ const part = partOf(readPlanFileField(join(cwd, opWavePlanPath(spec, k, run.target)), "changeSet"));
970
+ return part ? [[run.target, part] as const] : [];
971
+ }));
972
+ return { members, ...(parts.size > 0 ? { parts } : {}) };
973
+ }
773
974
  const runsPath = writeRunsFile(at, runs, undefined, undefined, undefined, discover);
774
975
  const plans = opWavePlansPath(spec, k);
775
976
  rmSync(join(cwd, plans), { force: true });
776
- const code = exec(opWaveArgv(spec.planWave, { op: spec.op, wave: wave.name, runs: runsPath, plans }), cwd);
977
+ const planArgv = opWaveArgv(spec.planWave, { op: spec.op, wave: wave.name, runs: runsPath, plans });
978
+ const code = at.waveExec ? await at.waveExec(planArgv, cwd) : exec(planArgv, cwd);
777
979
  if (code !== 0) throw new Error(`planning wave ${k} (${wave.name}) exited ${code}`);
778
980
  let parsed: unknown;
779
981
  try {
@@ -808,6 +1010,14 @@ function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string;
808
1010
  const count = Array.isArray(parsed) ? undefined : (parsed as { waves?: unknown }).waves;
809
1011
  if (count !== undefined && (!Number.isInteger(count) || (count as number) < 0)) throw new Error(`the plans file of wave ${k} (${plans}): \`waves\` must be the number of waves found, a whole number`);
810
1012
  const pending = Array.isArray(parsed) ? undefined : pendingFields((parsed as { pending?: unknown }).pending, `the plans file of wave ${k} (${plans})`);
1013
+ const changeSetDoc = Array.isArray(parsed) ? undefined : (parsed as { changeSet?: unknown }).changeSet;
1014
+ if (changeSetDoc !== undefined && (changeSetDoc === null || typeof changeSetDoc !== "object" || Array.isArray(changeSetDoc))) {
1015
+ throw new Error(`the plans file of wave ${k} (${plans}): \`changeSet\` must be a change-set document`);
1016
+ }
1017
+ const parts = new Map(runs.flatMap((run) => {
1018
+ const part = partOf((byTarget.get(run.target) as { changeSet?: unknown } | undefined)?.changeSet);
1019
+ return part ? [[run.target, part] as const] : [];
1020
+ }));
811
1021
  const members = runs.map((run) => {
812
1022
  const m = member(run.target, run.op ?? spec.op, byTarget.get(run.target)!);
813
1023
  const path = join(cwd, opWavePlanPath(spec, k, run.target));
@@ -824,17 +1034,261 @@ function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string;
824
1034
  }
825
1035
  return {
826
1036
  members,
1037
+ ...(parts.size > 0 ? { parts } : {}),
827
1038
  ...(pending ? { pending } : {}),
828
1039
  ...(overriders ? { overriders: overriders as string[] } : {}),
829
1040
  ...(overriders && overridersSource ? { overridersSource: overridersSource as string } : {}),
830
1041
  ...(extras ? { extras } : {}),
831
1042
  ...(count !== undefined ? { waves: count as number } : {}),
1043
+ ...(changeSetDoc !== undefined ? { changeSet: changeSetDoc as ChangeSetDocument } : {}),
832
1044
  };
833
1045
  }
834
1046
 
1047
+ /**
1048
+ * Plan `runs` of wave `k` (#4545): through the spec's `step` when it names
1049
+ * one, each run's plan kept on `at.steps` for its apply, else with the
1050
+ * commands ({@link planRuns}).
1051
+ */
1052
+ async function planWaveRuns(
1053
+ at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec; options: Pick<RunOpWaveOptions, "capabilities" | "lockGrain" | "base" | "waveExec">; steps?: Map<string, OpWaveStepPlan> },
1054
+ runs: readonly OpWaveRun[],
1055
+ discover = false,
1056
+ ): Promise<PlannedRuns> {
1057
+ const { spec, k, wave, cwd } = at;
1058
+ if (!spec.step) return planRuns({ ...at, ...(at.options.waveExec ? { waveExec: at.options.waveExec } : {}) }, runs, discover);
1059
+ const registry = await opWaveRegistry(at.options, cwd, at.options.capabilities);
1060
+ const base = (at as { gateRule?: { base: string } }).gateRule?.base ?? at.options.base;
1061
+ const lockGrain = at.options.lockGrain ?? (await declaredLockGrain(cwd, base));
1062
+ // #4613: a step's own policy engine (CrossGuard) reads its packs at the base the wave's rules were read at.
1063
+ const policyBase = base && base !== "HEAD" ? base : undefined;
1064
+ const plans: OpWaveStepPlan[] = [];
1065
+ for (const run of runs) {
1066
+ const plan = await planOpWaveStep({ spec, wave, cwd, registry, planPath: opWavePlanPath(spec, k, run.target), lockGrain, ...(policyBase ? { policyBase } : {}) }, run);
1067
+ at.steps?.set(run.target, plan);
1068
+ plans.push(plan);
1069
+ }
1070
+ const members = plans.map((p) => ({
1071
+ member: p.target,
1072
+ planDigest: p.planDigest,
1073
+ op: runs.find((r) => r.target === p.target)?.op ?? spec.op,
1074
+ ...(p.destructive ? { destructive: true } : {}),
1075
+ ...(p.empty ? { empty: true } : {}),
1076
+ }));
1077
+ const parts = new Map(plans.flatMap((p) => (p.part ? [[p.target, p.part] as const] : [])));
1078
+ const changeSet = opWaveStepChangeSet(plans);
1079
+ return { members, ...(parts.size > 0 ? { parts } : {}), ...(changeSet ? { changeSet } : {}) };
1080
+ }
1081
+
1082
+ /**
1083
+ * `ci.lockGrain` of the member holding `cwd` (#4552), read at `base`, behind
1084
+ * a dynamic import so the wave-job runtime bundle leaves the declaration
1085
+ * reader out. Null when none is declared or the declaration cannot be read
1086
+ * there: each run then takes its lexicon's default.
1087
+ */
1088
+ async function declaredLockGrain(cwd: string, base: string | undefined): Promise<LockGrain | null> {
1089
+ try {
1090
+ const { ciLockGrainAt } = await import("../workspace/ci-lock-grain");
1091
+ return ciLockGrainAt(cwd, base);
1092
+ } catch {
1093
+ return null;
1094
+ }
1095
+ }
1096
+
1097
+ /**
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.
1101
+ */
1102
+ async function leaseWaveRows(
1103
+ options: RunOpWaveOptions,
1104
+ ctx: WaveContext,
1105
+ runs: readonly OpWaveRun[],
1106
+ ): 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 : [];
1110
+ });
1111
+ if (rows.length === 0) return undefined;
1112
+ const { leaseLockRows } = await import("../lifecycle/resource-lock");
1113
+ const { PR_APPLY_GATE } = await import("../pr-loop");
1114
+ 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)}` };
1120
+ }
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 } : {}) } };
1124
+ }
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
+ }
1129
+
1130
+ /** A wave's cost hold over its plans (#4545): each changing run priced, the sum against `approveAbove`. */
1131
+ function costVerdictOf(
1132
+ hold: NonNullable<OpWaveHolds["cost"]>,
1133
+ spec: OpWavesSpec,
1134
+ k: number,
1135
+ members: readonly OpWaveMember[],
1136
+ steps: ReadonlyMap<string, OpWaveStepPlan> | undefined,
1137
+ cwd: string,
1138
+ exec?: GatePolicyExec,
1139
+ ) {
1140
+ const runs = members.map((m) => ({ target: m.member, plan: opWavePlanPath(spec, k, m.member), artifact: steps?.get(m.member)?.artifact, empty: m.empty === true }));
1141
+ return opWaveCostVerdict(hold, opWaveCosts(hold, runs, cwd, exec));
1142
+ }
1143
+
1144
+ /**
1145
+ * Run a wave's holds over its plans (#4545): the policy marks each run it
1146
+ * denies or holds (the gate then settles them as a product's plan file
1147
+ * would), and the cost adds its digest member and, over its amount, a hold.
1148
+ * `failed` when the policy cannot run, or a run gave it no change set.
1149
+ */
1150
+ async function runWaveHolds(
1151
+ ctx: WaveContext,
1152
+ holds: OpWaveHolds | undefined,
1153
+ members: OpWaveMember[],
1154
+ parts: ReadonlyMap<string, ChangeSetPart> | undefined,
1155
+ base: string,
1156
+ ): Promise<{ holds: string[]; extras: WaveMember[]; rows: Map<string, OpRunPolicyRow>; policySource?: ResolvedGatePolicySource } | { failed: string }> {
1157
+ const { spec, k, wave, cwd, log, options } = ctx;
1158
+ // #4614: each run's ci.policy row, which the after-plan hooks and the run record read.
1159
+ const out: { holds: string[]; extras: WaveMember[]; rows: Map<string, OpRunPolicyRow>; policySource?: ResolvedGatePolicySource } = { holds: [], extras: [], rows: new Map<string, OpRunPolicyRow>() };
1160
+ if (!holds) return out;
1161
+ if (holds.policy) {
1162
+ const missing = members.filter((m) => !parts?.has(m.member)).map((m) => m.member);
1163
+ if (missing.length > 0) return { failed: `wave ${k} (${wave.name}): holds.policy reads each run's change set, and the plans of ${missing.join(", ")} gave none, so nothing in it was applied` };
1164
+ let head = options.head;
1165
+ if (!head) {
1166
+ try {
1167
+ head = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
1168
+ } catch {
1169
+ head = "";
1170
+ }
1171
+ }
1172
+ let got: Awaited<ReturnType<typeof opWavePolicyVerdicts>>;
1173
+ try {
1174
+ got = await opWavePolicyVerdicts({ spec, gate: opWaveGateName(spec, k), env: spec.labels?.Env ?? wave.name, base, head, cwd, ...(options.holdExec ? { exec: options.holdExec } : {}) }, parts!);
1175
+ } catch (err) {
1176
+ return { failed: `wave ${k} (${wave.name}): ${err instanceof Error ? err.message : String(err)}, so nothing in it was applied` };
1177
+ }
1178
+ if ("note" in got) log(`wave ${k} (${wave.name}): ${got.note}`);
1179
+ else {
1180
+ if (got.source) {
1181
+ out.policySource = got.source;
1182
+ log(`wave ${k} (${wave.name}): ci.policy read from ${got.source.repo}@${got.source.ref} at commit ${got.source.commit}`);
1183
+ }
1184
+ for (const m of members) {
1185
+ const v = got.verdicts.get(m.member);
1186
+ if (v && v.result !== "error") {
1187
+ const rules = v.result === "held" ? v.holds : v.result === "denied" ? v.rules : [];
1188
+ out.rows.set(m.member, { source: "ci.policy", result: v.result, rules, ...(v.reason ? { reason: v.reason } : {}) });
1189
+ }
1190
+ if (!v || v.result === "passed") continue;
1191
+ if (v.result === "error") return { failed: `wave ${k} (${wave.name}): the policy did not run on ${m.member} (${v.reason ?? "no answer"}), so nothing in it was applied` };
1192
+ if (v.result === "denied") m.denied = { rules: v.rules, ...(v.reason ? { reason: v.reason } : {}) };
1193
+ else m.held = { rules: v.holds, ...(v.reason ? { reason: v.reason } : {}) };
1194
+ }
1195
+ }
1196
+ }
1197
+ if (holds.cost) {
1198
+ const verdict = costVerdictOf(holds.cost, spec, k, members, ctx.steps, cwd, options.holdExec);
1199
+ out.extras.push(verdict.member);
1200
+ log(`wave ${k} (${wave.name}): cost ${verdict.monthlyDelta >= 0 ? "+" : ""}${verdict.monthlyDelta.toFixed(2)} ${verdict.currency} a month${verdict.unestimated.length ? `, ${verdict.unestimated.length} run${verdict.unestimated.length === 1 ? "" : "s"} not priced` : ""}`);
1201
+ if (verdict.hold) out.holds.push(verdict.hold);
1202
+ }
1203
+ return out;
1204
+ }
1205
+
1206
+ /** The job's after-plan hooks (#4614), as a list. */
1207
+ function afterPlanHooks(options: RunOpWaveOptions): readonly OpWaveAfterPlanHook[] {
1208
+ const given = options.afterPlan;
1209
+ if (given === undefined) return [];
1210
+ return Array.isArray(given) ? (given as readonly OpWaveAfterPlanHook[]) : [given as OpWaveAfterPlanHook];
1211
+ }
1212
+
1213
+ /**
1214
+ * Run the after-plan hooks in the job's process over a wave's plans (#4614),
1215
+ * fold their policy rows into each run's denial and hold, and put each run's
1216
+ * rows and files on the result for the run record. With no hook, the rows
1217
+ * chant's `holds.policy` gave still go on the result.
1218
+ */
1219
+ async function runAfterPlan(
1220
+ ctx: WaveContext,
1221
+ members: OpWaveMember[],
1222
+ parts: ReadonlyMap<string, ChangeSetPart> | undefined,
1223
+ policyRows: ReadonlyMap<string, OpRunPolicyRow>,
1224
+ ): Promise<{ failed?: string; holds: string[] }> {
1225
+ const { spec, k, wave, cwd, options, result } = ctx;
1226
+ const hooks = afterPlanHooks(options);
1227
+ const job: OpWaveAfterPlanRun["job"] = options.decide ? "decide" : options.group !== undefined ? "group" : options.share !== undefined ? "share" : "wave";
1228
+ const runs: OpWaveAfterPlanRun[] = members.map((m) => {
1229
+ const plan = opWavePlanPath(spec, k, m.member);
1230
+ const step = ctx.steps?.get(m.member);
1231
+ const planJson = runPlanJson(ctx, m.member, plan);
1232
+ const part = parts?.get(m.member) ?? step?.part;
1233
+ const row = policyRows.get(m.member);
1234
+ return {
1235
+ spec: spec.name,
1236
+ op: spec.op,
1237
+ wave: k,
1238
+ waveName: wave.name,
1239
+ job,
1240
+ target: m.member,
1241
+ runOp: m.op,
1242
+ planDigest: m.planDigest,
1243
+ plan,
1244
+ ...(planJson ? { planJson } : {}),
1245
+ ...(step?.artifact !== undefined ? { artifact: step.artifact } : {}),
1246
+ ...(part ? { changeSet: part } : {}),
1247
+ empty: m.empty === true,
1248
+ destructive: m.destructive === true,
1249
+ policy: row ? [row] : [],
1250
+ cwd,
1251
+ };
1252
+ });
1253
+ const out = hooks.length > 0 && runs.length > 0 ? await runOpWaveAfterPlanHooks(hooks, runs, ctx.log) : undefined;
1254
+ if (out) result.hooks.push(...out.outcomes);
1255
+ const plans: Record<string, OpRunWavePlan> = { ...(result.plans ?? {}) };
1256
+ for (const m of members) {
1257
+ const mine = out?.runs.get(m.member);
1258
+ const chant = policyRows.get(m.member);
1259
+ const rows = [...(chant ? [chant] : []), ...(mine?.policy ?? [])];
1260
+ if (mine?.policy.length) {
1261
+ const folded = foldPolicyRows(mine.policy, { ...(m.denied ? { denied: m.denied } : {}), ...(m.held ? { held: m.held } : {}) });
1262
+ if (folded.denied) m.denied = folded.denied;
1263
+ if (folded.held) m.held = folded.held;
1264
+ }
1265
+ if (rows.length === 0 && !mine?.files.length) continue;
1266
+ plans[m.member] = { planDigest: m.planDigest, ...(rows.length ? { policy: rows } : {}), ...(mine?.files.length ? { files: [...mine.files] } : {}) };
1267
+ }
1268
+ if (Object.keys(plans).length > 0) result.plans = plans;
1269
+ return { ...(out?.failed ? { failed: out.failed } : {}), holds: out?.holds ?? [] };
1270
+ }
1271
+
1272
+ /** One field of a plan file, or undefined when the file or the field is missing. */
1273
+ function readPlanFileField(path: string, field: string): unknown {
1274
+ try {
1275
+ return (JSON.parse(readFileSync(path, "utf-8")) as Record<string, unknown>)[field];
1276
+ } catch {
1277
+ return undefined;
1278
+ }
1279
+ }
1280
+
1281
+ /** A plan file's change-set part (#4545), when it gives one of the right shape. */
1282
+ function partOf(value: unknown): ChangeSetPart | undefined {
1283
+ const p = value as Partial<ChangeSetPart> | undefined;
1284
+ return p && typeof p === "object" && p.member && typeof p.member.member === "string" && Array.isArray(p.entries) ? (p as ChangeSetPart) : undefined;
1285
+ }
1286
+
835
1287
  /** What planning a wave's runs gave: each run's plan, and the product's pending-fact fields (#3821). */
836
1288
  interface PlannedRuns {
837
1289
  members: OpWaveMember[];
1290
+ /** Each run's change-set part, by target, when its plan gave one (#4545): what a policy hold reads. */
1291
+ parts?: Map<string, ChangeSetPart>;
838
1292
  pending?: Record<string, unknown>;
839
1293
  /** The plans file's overriders (#3821). */
840
1294
  overriders?: string[];
@@ -842,6 +1296,8 @@ interface PlannedRuns {
842
1296
  overridersSource?: string;
843
1297
  /** Digest members that are not runs, such as the wave's cost (#3821). */
844
1298
  extras?: WaveMember[];
1299
+ /** The change-set document the plans file gave (#4551). */
1300
+ changeSet?: ChangeSetDocument;
845
1301
  /** How many waves the product found (#3821), for a `rest` wave. */
846
1302
  waves?: number;
847
1303
  }
@@ -884,8 +1340,22 @@ interface HooksOutcome {
884
1340
 
885
1341
  const placeOf = (ctx: WaveContext): HookPlace => ({ name: ctx.spec.name, op: ctx.spec.op, waveName: ctx.wave.name, k: ctx.k, cwd: ctx.cwd, exec: ctx.exec, log: ctx.log });
886
1342
 
887
- const hookRuns = (spec: OpWavesSpec, k: number, runs: readonly OpWaveRun[], members?: ReadonlyMap<string, OpWaveMember>): OpWaveHookRun[] =>
888
- runs.map((run) => ({ target: run.target, op: run.op ?? spec.op, ...(members?.has(run.target) ? { plan: opWavePlanPath(spec, k, run.target) } : {}) }));
1343
+ const hookRuns = (ctx: WaveContext, runs: readonly OpWaveRun[], members?: ReadonlyMap<string, OpWaveMember>): OpWaveHookRun[] =>
1344
+ runs.map((run) => {
1345
+ const { spec, k } = ctx;
1346
+ const m = members?.get(run.target);
1347
+ if (!m) return { target: run.target, op: run.op ?? spec.op };
1348
+ const plan = opWavePlanPath(spec, k, run.target);
1349
+ // #4614: the engine's plan document, from the step's artifact or the plan file's.
1350
+ const planJson = runPlanJson(ctx, run.target, plan);
1351
+ return { target: run.target, op: run.op ?? spec.op, plan, planDigest: m.planDigest, ...(planJson ? { planJson } : {}) };
1352
+ });
1353
+
1354
+ /** The engine's plan document a run's plan names (#4614): the step's artifact, else the plan file's `artifact`. */
1355
+ function runPlanJson(ctx: Pick<WaveContext, "cwd" | "steps">, target: string, plan: string): string | undefined {
1356
+ const artifact = ctx.steps?.get(target)?.artifact ?? readPlanFileField(join(ctx.cwd, plan), "artifact");
1357
+ return planJsonOf(artifact, ctx.cwd);
1358
+ }
889
1359
 
890
1360
  /**
891
1361
  * Run one moment's hooks in the wave job (#3762), recording each outcome on
@@ -906,7 +1376,10 @@ async function runHooks(
906
1376
  ): Promise<HooksOutcome> {
907
1377
  if (!hooks || hooks.length === 0) return { holds: [] };
908
1378
  const runsPath = writeRunsFile(ctx, runs, members, digest);
909
- const out = runHookList(placeOf(ctx), moment, hooks, hookRuns(ctx.spec, ctx.k, runs, members), runsPath, extraEnv);
1379
+ const hookExec = ctx.options.hookExec;
1380
+ const out = hookExec
1381
+ ? await runHookListAsync({ ...placeOf(ctx), exec: hookExec }, moment, hooks, hookRuns(ctx, runs, members), runsPath, extraEnv)
1382
+ : runHookList(placeOf(ctx), moment, hooks, hookRuns(ctx, runs, members), runsPath, extraEnv);
910
1383
  ctx.result.hooks.push(...out.outcomes);
911
1384
  const back: HooksOutcome = { holds: out.holds, ...(out.failed ? { failed: out.failed } : {}) };
912
1385
  if (out.failed) return back;
@@ -923,7 +1396,8 @@ async function runHooks(
923
1396
  }
924
1397
  const now: OpWaveHeldOnApproval = { op: held.op, gate: held.gate, digest: held.digest, approvedBy: held.approvedBy!, approvedAt: held.approvedAt! };
925
1398
  approved.push(now);
926
- const approvedEnv = {
1399
+ const target = hold.target ? { target: hold.target } : {};
1400
+ const approvedEnv: Record<string, string> = {
927
1401
  ...hold.env,
928
1402
  CHANT_HOLD_APPROVED: JSON.stringify(now),
929
1403
  // Every hold this hook call was approved through so far, oldest first (#3847).
@@ -931,14 +1405,31 @@ async function runHooks(
931
1405
  };
932
1406
  const holdPath = join(ctx.cwd, hold.env.CHANT_HOLD!);
933
1407
  rmSync(holdPath, { force: true });
1408
+ // #4623: a hold that asks chant to record its gate is spent here, before the re-run acts under the approval.
1409
+ let spent: AppliedGateRecord | undefined;
1410
+ let finishedAt: string | undefined;
1411
+ if (hold.request.record) {
1412
+ const got = await spendHeldGate(ctx, hold, now);
1413
+ if ("failed" in got) {
1414
+ ctx.result.hooks.push({ moment, name: hold.name, ...target, exit: 1, outcome: "failed" });
1415
+ back.failed = got.failed;
1416
+ ctx.log(back.failed);
1417
+ return back;
1418
+ }
1419
+ spent = got.record;
1420
+ const finishedRel = holdFinishedPath(hold.env.CHANT_HOLD!);
1421
+ finishedAt = join(ctx.cwd, finishedRel);
1422
+ rmSync(finishedAt, { force: true });
1423
+ approvedEnv.CHANT_HOLD_FINISHED = finishedRel;
1424
+ }
934
1425
  let code: number;
935
1426
  try {
936
- code = ctx.exec(hold.argv, ctx.cwd, approvedEnv);
1427
+ code = hookExec ? await hookExec(hold.argv, ctx.cwd, approvedEnv) : ctx.exec(hold.argv, ctx.cwd, approvedEnv);
937
1428
  } catch (err) {
938
1429
  ctx.log(`${hold.label} did not run: ${err instanceof Error ? err.message : String(err)}`);
939
1430
  code = 127;
940
1431
  }
941
- const target = hold.target ? { target: hold.target } : {};
1432
+ if (spent && finishedAt) await finishHeldGate(ctx, hold, spent, readHoldFinished(finishedAt, ctx.log, hold.label), code);
942
1433
  if (code === 0) {
943
1434
  ctx.result.hooks.push({ moment, name: hold.name, ...target, exit: code, outcome: "passed" });
944
1435
  ctx.log(`${hold.label}: ${held.approvedBy} approved ${held.op} / ${held.gate} at ${held.digest}, and the hook ran again and passed`);
@@ -1011,6 +1502,73 @@ function logRefused(log: (line: string) => void, label: string, check: GateCheck
1011
1502
  for (const { resolution: r, reason } of check.refused ?? []) log(`${label}: the approval by ${r.resolvedBy} at ${r.timestamp} does not count: ${reason}`);
1012
1503
  }
1013
1504
 
1505
+ /**
1506
+ * Spend a held gate's approval before the hook runs again under it (#4623),
1507
+ * when the hold asked chant to `record` the gate: an applied line in
1508
+ * `_gates/<op>/applied.jsonl`, as a gated request's (#4551). A digest that
1509
+ * already applied under this gate does not apply again, and a line that did
1510
+ * not reach the remote stops the re-run, so two jobs never act on one
1511
+ * approval.
1512
+ */
1513
+ async function spendHeldGate(ctx: WaveContext, hold: OtherGateHold, approval: OpWaveHeldOnApproval): Promise<{ record: AppliedGateRecord } | { failed: string }> {
1514
+ const { k, wave, cwd, options } = ctx;
1515
+ const port = options.gates ?? gitGateLedgerPort({ cwd });
1516
+ const label = `${approval.op} / ${approval.gate}`;
1517
+ try {
1518
+ if (!port.appendApplied) throw new Error("this gate ledger cannot record an applied approval");
1519
+ const prior = ((await port.readApplied?.(approval.op)) ?? []).filter((a) => a.gate === approval.gate && samePlanDigest(a.planDigest, approval.digest)).at(-1);
1520
+ if (prior) return { failed: `${hold.label}: ${label} at ${approval.digest} applied already under the approval by ${prior.approvedBy} (${prior.timestamp}); a held request applies once, so the hook did not run again` };
1521
+ const commit = typeof hold.request.pending?.commit === "string" ? hold.request.pending.commit : undefined;
1522
+ const runId = ciRunIdFromEnv();
1523
+ const record: AppliedGateRecord = {
1524
+ version: 1,
1525
+ kind: "applied",
1526
+ op: approval.op,
1527
+ gate: approval.gate,
1528
+ planDigest: approval.digest,
1529
+ approvedAt: approval.approvedAt,
1530
+ approvedBy: approval.approvedBy,
1531
+ timestamp: options.now ?? new Date().toISOString(),
1532
+ wave: { number: k, name: wave.name },
1533
+ ...(runId ? { runId } : {}),
1534
+ ...(commit ? { commit } : {}),
1535
+ };
1536
+ requireSpendPushed(await port.appendApplied(record));
1537
+ ctx.log(`${hold.label}: ${label} applies under the approval by ${record.approvedBy} at ${record.approvedAt}, which is now spent`);
1538
+ return { record };
1539
+ } catch (err) {
1540
+ return { failed: `${hold.label}: could not record that ${label} applies under the approval by ${approval.approvedBy}, so the hook did not run again: ${err instanceof Error ? err.message : String(err)}` };
1541
+ }
1542
+ }
1543
+
1544
+ /**
1545
+ * Write the finished line of a held gate the hook ran again under (#4623):
1546
+ * how it ended, from the hook's `CHANT_HOLD_FINISHED` file, else from its
1547
+ * exit code, with the file's detail. A line that is not written is logged;
1548
+ * the work under the approval is done either way.
1549
+ */
1550
+ async function finishHeldGate(ctx: WaveContext, hold: OtherGateHold, spent: AppliedGateRecord, wrote: OpWaveHoldFinished | undefined, code: number): Promise<void> {
1551
+ const port = ctx.options.gates ?? gitGateLedgerPort({ cwd: ctx.cwd });
1552
+ const record: FinishedGateRecord = {
1553
+ version: 1,
1554
+ kind: "finished",
1555
+ op: spent.op,
1556
+ gate: spent.gate,
1557
+ planDigest: spent.planDigest,
1558
+ applied: spent.timestamp,
1559
+ result: wrote?.result ?? (code === 0 ? "applied" : "failed"),
1560
+ timestamp: ctx.options.now ?? new Date().toISOString(),
1561
+ ...(wrote?.detail ? { detail: wrote.detail } : {}),
1562
+ };
1563
+ try {
1564
+ if (!port.appendFinished) throw new Error("this gate ledger keeps no finished lines");
1565
+ const pushed = await port.appendFinished(record);
1566
+ if (!pushed.pushed && pushed.pushWarning && !isLifecycleLocalNote(pushed.pushWarning)) ctx.log(`${hold.label}: the finished line of ${spent.op} / ${spent.gate} was written and not pushed: ${pushed.pushWarning}`);
1567
+ } catch (err) {
1568
+ ctx.log(`${hold.label}: the finished line of ${spent.op} / ${spent.gate} was not written: ${err instanceof Error ? err.message : String(err)}`);
1569
+ }
1570
+ }
1571
+
1014
1572
  /**
1015
1573
  * Settle a hold on another gate (#3821): an approval of that gate and digest
1016
1574
  * under the wave's approval mode (`pr-review` counts the ledger alone, since
@@ -1024,6 +1582,17 @@ async function settleOtherGate(ctx: WaveContext, hold: OtherGateHold): Promise<O
1024
1582
  const { port } = await gatePort(ctx.options, ctx.cwd, hold.request.gate, mode, rules.base);
1025
1583
  const neverOverMcp = rules.neverOverMcp;
1026
1584
  const now = ctx.options.now ?? new Date().toISOString();
1585
+ // #4623: the file the request carries, stored once before the pending fact, which names its SHA-256.
1586
+ const attachment = hold.request.attachment;
1587
+ if (attachment !== undefined) {
1588
+ try {
1589
+ if (!port.storeRequestAttachment) throw new Error("this gate ledger keeps no request files");
1590
+ await port.storeRequestAttachment(op, hold.request.digest, attachment);
1591
+ } catch (err) {
1592
+ log(`${op} / ${hold.request.gate}: the file ${hold.label} attached was not stored beside the pending fact: ${err instanceof Error ? err.message : String(err)}`);
1593
+ }
1594
+ }
1595
+ const proof = attachment !== undefined ? { proof: `sha256:${createHash("sha256").update(attachment).digest("hex")}` } : {};
1027
1596
  const check = await evaluateGate(port, {
1028
1597
  op,
1029
1598
  gate: hold.request.gate,
@@ -1031,7 +1600,7 @@ async function settleOtherGate(ctx: WaveContext, hold: OtherGateHold): Promise<O
1031
1600
  description: hold.request.description ?? `wave ${k} (${wave.name}) of ${spec.name} is held on it by ${hold.label}`,
1032
1601
  now,
1033
1602
  // #3839: the wave a hold belongs to, as a field, whatever the hook's own description says.
1034
- fields: { ...hold.request.pending, approvalMode: rules.approval, wave: { number: k, name: wave.name, op: spec.name }, heldBy: { hook: hold.name, moment: hold.moment, ...(hold.target ? { target: hold.target } : {}) } },
1603
+ fields: { ...hold.request.pending, ...proof, approvalMode: rules.approval, wave: { number: k, name: wave.name, op: spec.name }, heldBy: { hook: hold.name, moment: hold.moment, ...(hold.target ? { target: hold.target } : {}) } },
1035
1604
  ...(neverOverMcp ? { neverOverMcp: true } : {}),
1036
1605
  });
1037
1606
  const base = { op, gate: hold.request.gate, digest: hold.request.digest, hook: hold.label };
@@ -1195,8 +1764,227 @@ function noteHooksAtBase(ctx: WaveContext, rules: OpWaveBaseRules): void {
1195
1764
  * its plan command found.
1196
1765
  */
1197
1766
  export async function runOpWave(options: RunOpWaveOptions): Promise<RunOpWaveResult> {
1767
+ assertOpWavesSpec(options.spec);
1768
+ const afterPlanWrong = opWaveAfterPlanProblems(options.afterPlan);
1769
+ if (afterPlanWrong.length > 0) throw new Error(`Op waves "${options.spec.name}": ${afterPlanWrong.join("; ")}`);
1770
+ // #4551: one run record per job, on every way the job ends.
1771
+ const started = new Date().toISOString();
1772
+ // #4555: the job's run events and its trace, when a reader or an exporter wants them.
1773
+ const events = await openOpWaveEvents(options);
1774
+ if (events) jobEvents.set(options, events);
1775
+ events?.start();
1776
+ let result: RunOpWaveResult;
1777
+ try {
1778
+ result = await runOpWaveJob(options);
1779
+ } catch (err) {
1780
+ const record = await recordOpWaveRun(options, started, { error: err });
1781
+ await closeOpWaveEvents(options, events, record);
1782
+ throw err;
1783
+ }
1784
+ const record = await recordOpWaveRun(options, started, { result });
1785
+ await closeOpWaveEvents(options, events, record, result);
1786
+ return result;
1787
+ }
1788
+
1789
+ /** Each running job's events (#4555), by its options, which every step of the job is handed. */
1790
+ const jobEvents = new WeakMap<RunOpWaveOptions, OpWaveRunEvents>();
1791
+
1792
+ /** The job's run events (#4555): to `options.events`, and to a trace when the exporter is on. Undefined when neither wants them. */
1793
+ async function openOpWaveEvents(options: RunOpWaveOptions): Promise<OpWaveRunEvents | undefined> {
1794
+ const log = options.log ?? ((line: string) => console.error(line));
1795
+ let exporter: OtlpExporter | undefined;
1796
+ try {
1797
+ exporter = options.otlp === false ? undefined : (options.otlp ?? activeOtlp());
1798
+ } catch (err) {
1799
+ log(`wave ${options.wave}: no trace is sent: ${err instanceof Error ? err.message : String(err)}`);
1800
+ }
1801
+ if (!options.events && !exporter) return undefined;
1802
+ let trace: RunEventTrace | undefined;
1803
+ if (exporter) {
1804
+ const run = await resolveRunEventRun({ kind: "op", name: options.spec.name, cwd: options.cwd ?? process.cwd() });
1805
+ trace = new RunEventTrace(run, { exporter });
1806
+ }
1807
+ return new OpWaveRunEvents(joinRunEventSinks(options.events, trace?.sink)!, trace);
1808
+ }
1809
+
1810
+ /** Settle the job's events from its run record and send its trace (#4555). A trace that does not go out is a line in the log, never a change of exit code. */
1811
+ async function closeOpWaveEvents(options: RunOpWaveOptions, events: OpWaveRunEvents | undefined, record: OpRunRecordInput, result?: RunOpWaveResult): Promise<void> {
1812
+ if (!events) return;
1813
+ jobEvents.delete(options);
1814
+ events.finish(record, { ...(result ? { moved: result.moved } : {}), ...(result?.blocked ? { blocked: result.blocked } : {}) });
1815
+ const problem = await events.trace?.flush();
1816
+ if (problem) (options.log ?? ((line: string) => console.error(line)))(`wave ${options.wave}: the trace was not sent: ${problem}`);
1817
+ }
1818
+
1819
+ /** A target's apply began (#4555): its start time for the record, and its `step-start`. */
1820
+ function targetStarted(options: RunOpWaveOptions, k: number, target: string): number {
1821
+ jobEvents.get(options)?.stepStart(k, target);
1822
+ return Date.now();
1823
+ }
1824
+
1825
+ /** A target's apply ended (#4555): its time and facts on the result, and its `step-settle`. */
1826
+ function targetSettled(options: RunOpWaveOptions, result: RunOpWaveResult, k: number, target: string, startedMs: number, status: "ok" | "failed" | "skipped", opts: { error?: string; facts?: CapabilityTraceFacts } = {}): void {
1827
+ const durationMs = Math.max(0, Date.now() - startedMs);
1828
+ result.targets = {
1829
+ ...result.targets,
1830
+ [target]: {
1831
+ startedAt: new Date(startedMs).toISOString(),
1832
+ durationMs,
1833
+ ...(opts.facts?.attributes ? { attributes: opts.facts.attributes } : {}),
1834
+ ...(opts.facts?.spans?.length ? { spans: opts.facts.spans } : {}),
1835
+ },
1836
+ };
1837
+ jobEvents.get(options)?.stepSettle(k, target, status, durationMs, opts);
1838
+ // #4615: one log line per resource the engine reported.
1839
+ if (opts.facts?.resources?.length) {
1840
+ const log = options.log ?? ((line: string) => console.error(line));
1841
+ for (const line of opWaveResourceLines(target, opts.facts.resources)) log(line);
1842
+ }
1843
+ }
1844
+
1845
+ /** The log lines for what a target's engine reported per resource (#4615): `<target>: <resource> (<type>) ok in 412 ms, 3 calls`. */
1846
+ export function opWaveResourceLines(target: string, resources: readonly RunEventResource[]): string[] {
1847
+ return resources.map((r) => {
1848
+ const what = r.name ? `${r.name}${r.type ? ` (${r.type})` : ""}` : `${r.resource}${r.type ? ` (${r.type})` : ""}`;
1849
+ const took = r.durationMs === null ? "" : ` in ${Math.round(r.durationMs)} ms`;
1850
+ const calls = r.calls !== undefined ? `, ${r.calls} call${r.calls === 1 ? "" : "s"}` : "";
1851
+ return `${target}: ${what} ${r.status === "ok" ? "ok" : "failed"}${took}${calls}`;
1852
+ });
1853
+ }
1854
+
1855
+ /** The run ledger's status and failure for a job's exit code (#4551), by chant's exit-code table. */
1856
+ function opWaveRunStatus(result: RunOpWaveResult): { status: OpRunRecordInput["status"]; failure?: { code: string; reason: string } } {
1857
+ const d = result.decision;
1858
+ switch (result.exitCode) {
1859
+ case CHANT_EXIT.done:
1860
+ case CHANT_EXIT.held:
1861
+ case CHANT_EXIT.superseded:
1862
+ return { status: "ok" };
1863
+ case CHANT_EXIT.waiting:
1864
+ return { status: d?.point?.question ? "waiting" : "gated" };
1865
+ case CHANT_EXIT.moved:
1866
+ return { status: "fail", failure: { code: "moved", reason: `plans moved since the decision: ${result.moved.join(", ") || "(none named)"}` } };
1867
+ case CHANT_EXIT.denied:
1868
+ return { status: "fail", failure: { code: "denied", reason: d?.refused?.message ?? `the policy denied ${d?.refused?.runs.join(", ") ?? "a run"}, and no override counts` } };
1869
+ case CHANT_EXIT.declined:
1870
+ return { status: "fail", failure: { code: "point-refused", reason: d?.refused?.message ?? "the gate's decision point was answered with an answer it does not pass on" } };
1871
+ default:
1872
+ return { status: "fail", failure: { code: "command-failed", reason: result.failed.length > 0 ? `failed: ${result.failed.join(", ")}` : "the wave job failed" } };
1873
+ }
1874
+ }
1875
+
1876
+ /**
1877
+ * The run record of one `chant run wave` job (#4551): one phase per wave the
1878
+ * job walked, one step per run target. A run that applied is `ok`, one that
1879
+ * failed `fail`, and one that moved, was blocked or waited `skipped`.
1880
+ */
1881
+ export function opWaveRunRecord(
1882
+ options: Pick<RunOpWaveOptions, "spec" | "wave" | "decide" | "share" | "group">,
1883
+ times: { started: string; ended: string; gitSha?: string; runOrigin?: OpRunRecordInput["runOrigin"] },
1884
+ outcome: { result: RunOpWaveResult } | { error: unknown },
1885
+ ): OpRunRecordInput {
1886
+ const { spec } = options;
1887
+ const result: RunOpWaveResult = "result" in outcome ? outcome.result : { exitCode: CHANT_EXIT.failed, applied: [], failed: [], moved: [], hooks: [] };
1888
+ const d = result.decision;
1889
+ const applied = new Set(result.applied);
1890
+ const failedRuns = new Set(result.failed);
1891
+ const walked = result.rest?.length ? result.rest.map((r) => r.wave) : [options.wave];
1892
+ const last = walked[walked.length - 1];
1893
+ const phases = walked.map((k) => {
1894
+ const targets = k === last && d ? d.members.map((m) => m.member) : (spec.waves[k - 1]?.runs ?? []).map((r) => r.target);
1895
+ const steps: OpRunStepRecord[] = targets.map((t) => ({
1896
+ fn: t,
1897
+ status: failedRuns.has(t) ? "fail" : applied.has(t) ? "ok" : "skipped",
1898
+ durationMs: result.targets?.[t]?.durationMs ?? 0,
1899
+ }));
1900
+ const status: "ok" | "fail" | "skipped" = steps.some((x) => x.status === "fail") ? "fail" : steps.length > 0 && steps.every((x) => x.status === "skipped") ? "skipped" : "ok";
1901
+ return { name: `wave-${k}`, status, steps };
1902
+ });
1903
+ const verdict: ReturnType<typeof opWaveRunStatus> = "error" in outcome
1904
+ ? { status: "fail", failure: { code: "command-failed", reason: outcome.error instanceof Error ? outcome.error.message : String(outcome.error) } }
1905
+ : opWaveRunStatus(result);
1906
+ const wave: OpRunWave = {
1907
+ spec: spec.name,
1908
+ number: options.wave,
1909
+ name: spec.waves[options.wave - 1]?.name ?? `wave-${options.wave}`,
1910
+ job: options.decide ? "decide" : options.group !== undefined ? "group" : options.share !== undefined ? "share" : "wave",
1911
+ ...(options.share !== undefined ? { share: options.share } : {}),
1912
+ ...(options.group !== undefined ? { group: options.group } : {}),
1913
+ ...(d?.digest ? { digest: d.digest } : {}),
1914
+ exitCode: result.exitCode,
1915
+ ...(result.outcome && result.outcome.outcome !== "replan" ? { outcome: result.outcome.outcome } : {}),
1916
+ ...(result.supersededBy ? { supersededBy: { ...result.supersededBy } } : {}),
1917
+ applied: [...result.applied],
1918
+ failed: [...result.failed],
1919
+ moved: [...result.moved],
1920
+ ...(result.blocked && Object.keys(result.blocked).length > 0 ? { blocked: { ...result.blocked } } : {}),
1921
+ ...(result.targets && Object.keys(result.targets).length > 0 ? { targets: { ...result.targets } } : {}),
1922
+ ...(result.plans && Object.keys(result.plans).length > 0 ? { plans: { ...result.plans } } : {}),
1923
+ };
1924
+ const labels = { ...(spec.labels ?? {}) };
1925
+ return {
1926
+ op: spec.name,
1927
+ env: labels.Env ?? DEFAULT_RUN_ENV,
1928
+ started: times.started,
1929
+ ended: times.ended,
1930
+ status: verdict.status,
1931
+ labels,
1932
+ outcomes: {},
1933
+ phases,
1934
+ ...(verdict.status === "gated" && d ? { gate: { name: d.gate, since: d.waitingSince ?? times.ended, ...(d.op !== spec.name ? { op: d.op } : {}) } } : {}),
1935
+ ...(verdict.status === "waiting" && d?.point?.question ? { point: { ...d.point.question, since: d.waitingSince ?? times.ended } } : {}),
1936
+ ...(times.gitSha ? { gitSha: times.gitSha } : {}),
1937
+ ...(times.runOrigin ? { runOrigin: times.runOrigin } : {}),
1938
+ ...(verdict.failure ? { failure: { ...verdict.failure, exitCode: result.exitCode } } : {}),
1939
+ wave,
1940
+ };
1941
+ }
1942
+
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> {
1945
+ const cwd = options.cwd ?? process.cwd();
1946
+ const port = options.runs ?? (options.gates ? undefined : gitOpWaveRunPort({ cwd }));
1947
+ const log = options.log ?? ((line: string) => console.error(line));
1948
+ let gitSha = options.head;
1949
+ if (gitSha === undefined) {
1950
+ try {
1951
+ gitSha = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
1952
+ } catch {
1953
+ gitSha = undefined;
1954
+ }
1955
+ }
1956
+ const ci = resolveCiJob();
1957
+ const record = opWaveRunRecord(options, { started, ended: new Date().toISOString(), ...(gitSha ? { gitSha } : {}), ...(ci ? { runOrigin: ci.runOrigin } : {}) }, outcome);
1958
+ // The record is built either way: the job's run events settle from it (#4555).
1959
+ if (!port) return record;
1960
+ try {
1961
+ const wrote = await port.append(record);
1962
+ if (wrote && wrote.pushWarning) log(`wave ${options.wave}: the run record was written and not pushed: ${wrote.pushWarning}`);
1963
+ } catch (err) {
1964
+ log(`wave ${options.wave}: could not record the run on the run ledger: ${err instanceof Error ? err.message : String(err)}`);
1965
+ }
1966
+ return record;
1967
+ }
1968
+
1969
+ /**
1970
+ * Store the change-set document a wave's plans file gave (#4551), so the
1971
+ * pending fact can cite it. A document that is not one, or does not hash to
1972
+ * its digest, is logged and left out; it never blocks the gate.
1973
+ */
1974
+ async function storeWaveChangeSet(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, doc: ChangeSetDocument): Promise<void> {
1975
+ const ledger = options.gates ?? gitGateLedgerPort({ cwd: ctx.cwd });
1976
+ if (!ledger.storeChangeSet) return;
1977
+ try {
1978
+ await ledger.storeChangeSet(doc);
1979
+ decision.changeSet = doc.digest;
1980
+ } catch (err) {
1981
+ ctx.log(`wave ${ctx.k} (${ctx.wave.name}): the plans file's change set was not stored, so the pending fact cites none: ${err instanceof Error ? err.message : String(err)}`);
1982
+ }
1983
+ }
1984
+
1985
+ /** One job's plan, decide and apply, which {@link runOpWave} records. */
1986
+ async function runOpWaveJob(options: RunOpWaveOptions): Promise<RunOpWaveResult> {
1198
1987
  const { spec } = options;
1199
- assertOpWavesSpec(spec);
1200
1988
  const log = options.log ?? ((line: string) => console.error(line));
1201
1989
  const cwd = options.cwd ?? process.cwd();
1202
1990
  const outcomeDir = options.outcomeDir ?? opWaveOutcomeDir(spec);
@@ -1244,6 +2032,8 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
1244
2032
  const { spec } = options;
1245
2033
  const last = spec.waves[spec.waves.length - 1]!;
1246
2034
  const rest: NonNullable<RunOpWaveResult["rest"]> = [];
2035
+ // #4555: each wave a `rest` job walks keeps its targets' times.
2036
+ const targets: Record<string, OpRunWaveTarget> = {};
1247
2037
  const result = await runWaveLoop<OpWavePlanned, OpWaveDecided, RunOpWaveResult>({
1248
2038
  first: options.wave,
1249
2039
  plan: (at) => planOpWave(options, at, at.k === options.wave ? skip : undefined),
@@ -1263,6 +2053,7 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
1263
2053
  },
1264
2054
  onward(k, outcome) {
1265
2055
  applied.push(...outcome.applied);
2056
+ Object.assign(targets, outcome.targets ?? {});
1266
2057
  // #3821: a `rest` wave goes on through the waves its plan command found.
1267
2058
  const found = outcome.decision?.discovered?.waves;
1268
2059
  const onward = k >= spec.waves.length && last.rest === true && options.share === undefined && options.group === undefined && !options.decide && outcome.exitCode === 0 && found !== undefined && k < found;
@@ -1271,7 +2062,8 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
1271
2062
  return onward;
1272
2063
  },
1273
2064
  });
1274
- return { ...result, applied, ...(rest.length > 0 ? { rest } : {}) };
2065
+ const timed = { ...targets, ...(result.targets ?? {}) };
2066
+ return { ...result, applied, ...(rest.length > 0 ? { rest } : {}), ...(Object.keys(timed).length > 0 ? { targets: timed } : {}) };
1275
2067
  }
1276
2068
 
1277
2069
  /** What the earlier outcome files hold for a job (#4322): the runs they block, or why the job does not run at all. */
@@ -1324,7 +2116,7 @@ function opWaveBefore(options: RunOpWaveOptions, dir: string): OpWaveBefore {
1324
2116
  ? `Nothing in wave ${k} (${wave.name}) ran: ${shown} waits at its gate. Approve it and run that wave's job again, then this one.`
1325
2117
  : `Nothing in wave ${k} (${wave.name}) ran: ${shown} did not apply, and only a failure lets the waves after it go on.`;
1326
2118
  const status = waiting.length > 0 ? "waiting" : "not-applied";
1327
- return { blocked: new Map(), stop: { exitCode: waiting.length > 0 ? 3 : 1, line, members: Object.fromEntries((wave.runs ?? []).map((r) => [r.target, { status }])) } };
2119
+ return { blocked: new Map(), stop: { exitCode: waiting.length > 0 ? CHANT_EXIT.waiting : CHANT_EXIT.failed, line, members: Object.fromEntries((wave.runs ?? []).map((r) => [r.target, { status }])) } };
1328
2120
  }
1329
2121
  const runs = wave.runs ?? [];
1330
2122
  const index = new Map(runs.map((r, i) => [r.target, i]));
@@ -1366,9 +2158,9 @@ function writeOpWaveOutcome(options: RunOpWaveOptions, dir: string, result: RunO
1366
2158
  const moved = new Set(result.moved);
1367
2159
  const otherwise: WaveMemberOutcome["status"] =
1368
2160
  result.exitCode === 0 ? (options.decide ? "decided" : "unchanged")
1369
- : result.exitCode === 3 ? "waiting"
1370
- : result.exitCode === 7 || result.exitCode === 8 ? "refused"
1371
- : result.exitCode >= 4 && result.exitCode <= 6 ? "not-applied"
2161
+ : result.exitCode === CHANT_EXIT.waiting ? "waiting"
2162
+ : result.exitCode === CHANT_EXIT.denied || result.exitCode === CHANT_EXIT.declined ? "refused"
2163
+ : result.exitCode >= CHANT_EXIT.moved && result.exitCode <= CHANT_EXIT.superseded ? "not-applied"
1372
2164
  : "failed";
1373
2165
  for (const t of targets) {
1374
2166
  const by = result.blocked?.[t];
@@ -1416,6 +2208,7 @@ type OpWavePlanned =
1416
2208
  overriders?: string[];
1417
2209
  overridersSource?: string;
1418
2210
  extras?: WaveMember[];
2211
+ changeSet?: ChangeSetDocument;
1419
2212
  }
1420
2213
  | {
1421
2214
  kind: "share";
@@ -1480,7 +2273,7 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
1480
2273
  ctx.gateRule = { approval: decision.approval, base: decision.base, neverOverMcp: decision.neverOverMcp === true };
1481
2274
  if (decision.status === "waiting" || decision.status === "refused") {
1482
2275
  log(`wave ${k} (${wave.name}) is ${decision.status === "refused" ? "refused by its policy" : `waiting on ${decision.heldOn?.gate ?? decision.gate}`}; nothing applied. ${decision.approve ?? ""}`.trim());
1483
- return { end: { ...result, exitCode: decision.status === "refused" ? refusedExit(decision) : 3 } };
2276
+ return { end: { ...result, exitCode: decision.status === "refused" ? refusedExit(decision) : CHANT_EXIT.waiting } };
1484
2277
  }
1485
2278
  // The share runs the hooks its deciding job read at base, around its own slice.
1486
2279
  if (wave.discover) {
@@ -1499,12 +2292,16 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
1499
2292
  const before = await runBeforePlanHooks(ctx, decision.hooks, slice);
1500
2293
  if (before.failed) return { end: failed(ctx, `a hook before the plan failed, so nothing in ${part} of wave ${k} was planned or applied`) };
1501
2294
  if (before.waitingOn) return { end: await waitOnOther(ctx, decision, before.waitingOn) };
1502
- const { members } = planRuns(ctx, slice);
2295
+ if (spec.step) ctx.steps = new Map();
2296
+ const { members, parts: sliceParts } = await planWaveRuns(ctx, slice);
2297
+ // #4614: the after-plan hooks in the job's process, over the share's own plans.
2298
+ const inProcess = await runAfterPlan(ctx, members, sliceParts, new Map());
2299
+ if (inProcess.failed) return { end: failed(ctx, `${inProcess.failed}, so nothing in ${part} of wave ${k} was applied`) };
1503
2300
  const planned = new Map(members.map((m) => [m.member, m]));
1504
2301
  const after = await runHooks(ctx, "after-plan", decision.hooks?.["after-plan"], slice, planned);
1505
2302
  if (after.failed) return { end: failed(ctx, `a hook after the plan failed, so nothing in ${part} of wave ${k} was applied`) };
1506
2303
  if (after.waitingOn) return { end: await waitOnOther(ctx, decision, after.waitingOn) };
1507
- return { go: { kind: "share", ctx, decision, slice, planned, holds: [...before.holds, ...after.holds] } };
2304
+ return { go: { kind: "share", ctx, decision, slice, planned, holds: [...before.holds, ...inProcess.holds, ...after.holds] } };
1508
2305
  }
1509
2306
 
1510
2307
  // The policy, the approval mode and the hooks, read at base before anything runs.
@@ -1559,7 +2356,27 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
1559
2356
  const before = await runBeforePlanHooks(ctx, rules.hooks, wave.runs);
1560
2357
  if (before.failed) return { end: failed(ctx, `a hook before the plan failed, so nothing in wave ${k} was planned or applied`) };
1561
2358
  if (before.waitingOn) return { end: await decided(ctx, decision, recordPath, before.waitingOn) };
1562
- const { members, pending, overriders, overridersSource, extras, waves: found } = planRuns(ctx, wave.runs, wave.discover === true);
2359
+ if (spec.step) ctx.steps = new Map();
2360
+ const { members, pending, overriders, overridersSource, extras: planExtras, waves: found, changeSet, parts } = await planWaveRuns(ctx, wave.runs, wave.discover === true);
2361
+ // #4545: the holds at base (else the change's), run over the plans before the gate decides.
2362
+ let extras = planExtras;
2363
+ let policyRows = new Map<string, OpRunPolicyRow>();
2364
+ if (rules.holdsRefused) {
2365
+ holds.push(rules.holdsRefused);
2366
+ log(`wave ${k} (${wave.name}): ${rules.holdsRefused}, so none runs and the wave waits for an approval`);
2367
+ } else {
2368
+ const held = await runWaveHolds(ctx, opWaveHoldsAt(rules.holds, spec.holds), members, parts, base);
2369
+ if ("failed" in held) return { end: failed(ctx, held.failed) };
2370
+ holds.push(...held.holds);
2371
+ if (held.extras.length > 0) extras = [...(extras ?? []), ...held.extras];
2372
+ policyRows = held.rows;
2373
+ // #4613: the decision names the shared policy commit its runs were judged by.
2374
+ if (held.policySource) decision.ciPolicySource = held.policySource;
2375
+ }
2376
+ // #4614: the after-plan hooks in the job's process, before the set digest and the gate.
2377
+ const inProcess = await runAfterPlan(ctx, members, parts, policyRows);
2378
+ if (inProcess.failed) return { end: failed(ctx, `${inProcess.failed}, so nothing in wave ${k} was approved or applied`) };
2379
+ holds.push(...inProcess.holds);
1563
2380
  if (wave.discover) {
1564
2381
  wave = { ...wave, runs: members.map((m) => ({ target: m.member, ...(m.op !== spec.op ? { op: m.op } : {}) })) };
1565
2382
  ctx.wave = wave;
@@ -1585,6 +2402,7 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
1585
2402
  ...(overriders ? { overriders } : {}),
1586
2403
  ...(overridersSource ? { overridersSource } : {}),
1587
2404
  ...(extras ? { extras } : {}),
2405
+ ...(changeSet ? { changeSet } : {}),
1588
2406
  },
1589
2407
  };
1590
2408
  }
@@ -1639,6 +2457,10 @@ async function decideOpWave(
1639
2457
  }
1640
2458
  if (extras) decision.extras = extras;
1641
2459
  if (pending) decision.pending = pending;
2460
+ if (planned.changeSet) await storeWaveChangeSet(options, ctx, decision, planned.changeSet);
2461
+ // #4550: a pull-request wave checks the pull request's approval against the plans file's change set.
2462
+ if (planned.changeSet) ctx.changeSetDoc = planned.changeSet;
2463
+ if (decision.approval === "pull-request" && planned.rules.pullRequestGate) decision.pullRequestGate = planned.rules.pullRequestGate;
1642
2464
  const after = await runHooks(ctx, "after-plan", planned.rules.hooks["after-plan"], wave.runs, planned.planned, digest);
1643
2465
  if (after.failed) return { end: failed(ctx, `a hook after the plan failed, so nothing in wave ${k} was applied`) };
1644
2466
  holds.push(...planned.before, ...after.holds);
@@ -1683,7 +2505,7 @@ async function decideOpWave(
1683
2505
  async function applyOpWave(options: RunOpWaveOptions, planned: OpWavePlanned, decidedWave: OpWaveDecided): Promise<RunOpWaveResult> {
1684
2506
  const { ctx, decision } = planned;
1685
2507
  await applyStage(options, ctx, decision, decidedWave.runs, planned.planned, decidedWave.earlierHolds, decidedWave.recordPath);
1686
- if (planned.kind === "share" && ctx.result.exitCode === 0 && ctx.result.moved.length > 0) ctx.result.exitCode = 4;
2508
+ if (planned.kind === "share" && ctx.result.exitCode === 0 && ctx.result.moved.length > 0) ctx.result.exitCode = CHANT_EXIT.moved;
1687
2509
  return ctx.result;
1688
2510
  }
1689
2511
 
@@ -1707,15 +2529,15 @@ async function decided(ctx: WaveContext, decision: OpWaveDecision, recordPath: s
1707
2529
  const hook = await runGateHooks(ctx, decision, recordPath);
1708
2530
  if (decision.status === "waiting") {
1709
2531
  log(`Nothing in wave ${k} or after it ran. ${decision.heldOn ? `It waits on ${decision.heldOn.op} / ${decision.heldOn.gate}.` : "Read the plans, then"} approve: ${decision.approve} (with --resume, the approval also starts this job again)`);
1710
- return { ...result, exitCode: 3 };
2532
+ return { ...result, exitCode: CHANT_EXIT.waiting };
1711
2533
  }
1712
2534
  if (decision.status === "refused" && decision.refused?.reason === "point") {
1713
2535
  log(`Nothing in wave ${k} (${wave.name}) or after it ran: ${decision.refused.message}`);
1714
- return { ...result, exitCode: 8 };
2536
+ return { ...result, exitCode: CHANT_EXIT.declined };
1715
2537
  }
1716
2538
  if (decision.status === "refused") {
1717
2539
  log(`Nothing in wave ${k} (${wave.name}) or after it ran: the policy denied ${decision.refused?.runs.join(", ")}, and no override counts for ${decision.refused?.runs.length === 1 ? "it" : "them"}.`);
1718
- return { ...result, exitCode: 7 };
2540
+ return { ...result, exitCode: CHANT_EXIT.denied };
1719
2541
  }
1720
2542
  if (hook.failed) return failed(ctx, `wave ${k} (${wave.name}): ${hook.failed}, so nothing in it was applied`);
1721
2543
  return result;
@@ -1734,7 +2556,7 @@ function markHeldOn(decision: OpWaveDecision, heldOn: OpWaveHeldOn): void {
1734
2556
  async function waitOnOther(ctx: WaveContext, decision: OpWaveDecision, heldOn: OpWaveHeldOn): Promise<RunOpWaveResult> {
1735
2557
  markHeldOn(decision, heldOn);
1736
2558
  ctx.log(`${shareLabel(ctx.options)} of wave ${ctx.k} (${ctx.wave.name}) waits on ${heldOn.op} / ${heldOn.gate}; nothing in it applied. Approve: ${heldOn.approve}`);
1737
- return { ...ctx.result, decision, exitCode: 3 };
2559
+ return { ...ctx.result, decision, exitCode: CHANT_EXIT.waiting };
1738
2560
  }
1739
2561
 
1740
2562
  /**
@@ -1883,7 +2705,7 @@ async function spendOverrides(ctx: WaveContext, decision: OpWaveDecision): Promi
1883
2705
 
1884
2706
  /** The exit code of a refused wave: 8 when its decision point refused it (#3836), 7 when the product's policy did (#3821). */
1885
2707
  function refusedExit(decision: OpWaveDecision): number {
1886
- return decision.refused?.reason === "point" ? 8 : 7;
2708
+ return decision.refused?.reason === "point" ? CHANT_EXIT.declined : CHANT_EXIT.denied;
1887
2709
  }
1888
2710
 
1889
2711
  function failed(ctx: WaveContext, line: string): RunOpWaveResult {
@@ -1907,7 +2729,17 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
1907
2729
  // #3784: under the spend rule at base, an approval a wave already applied under counts for nothing.
1908
2730
  const spent: AppliedGateRecord[] | undefined = decision.spend === "base" ? ((await ledger.readApplied?.(spec.name)) ?? []).filter((a) => a.gate === gate) : undefined;
1909
2731
  const held = decision.heldBy?.length ? `, held by ${decision.heldBy.join(", ")}` : "";
1910
- const check = await decideWaveGate(port, {
2732
+ // Under the pull request's approval the pending fact waits for the coverage check: a wave the
2733
+ // pull request's approval covers applies with no pending line at its own gate (#4588).
2734
+ let deferred: PendingGateInput | undefined;
2735
+ const deciding: typeof port = approval !== "pull-request" ? port : {
2736
+ ...port,
2737
+ async appendPending(input) {
2738
+ deferred = input;
2739
+ return { record: { version: 1, kind: "pending", ...input } as PendingGateRecord, pushed: false };
2740
+ },
2741
+ };
2742
+ const check = await decideWaveGate(deciding, {
1911
2743
  op: spec.name,
1912
2744
  gate,
1913
2745
  digest,
@@ -1915,7 +2747,7 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
1915
2747
  now,
1916
2748
  ...(spent ? { spent } : {}),
1917
2749
  // #3861: the approval mode the wave asked under, for readers deciding which approvals count.
1918
- fields: { ...decision.pending, approvalMode: approval },
2750
+ fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: approval },
1919
2751
  ...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
1920
2752
  });
1921
2753
  if (check.satisfied) {
@@ -1935,6 +2767,28 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
1935
2767
  if (used) {
1936
2768
  ctx.log(`wave ${k} (${wave.name}): the approval of ${digest} by ${used.approvedBy} at ${used.approvedAt} is spent: a wave applied under it at ${used.timestamp}. Applying it again needs a new approval`);
1937
2769
  }
2770
+ if (approval === "pull-request") {
2771
+ const covered = await approveByPullRequest(options, ctx, decision, ledger);
2772
+ decision.coveredBy = covered.digest ? { digest: covered.digest } : { reason: covered.reason };
2773
+ if (covered.digest) {
2774
+ for (const key of ["pendingFact", "recorded", "waitingSince", "mismatch"] as const) delete decision[key];
2775
+ decision.status = "approved";
2776
+ decision.via = "pull-request";
2777
+ decision.approvedBy = covered.approvedBy;
2778
+ decision.approvedAt = covered.approvedAt;
2779
+ ctx.log(`wave ${k} (${wave.name}) applies under the pull request's approval of ${covered.digest} at ${decision.pullRequestGate}, which covers its plans`);
2780
+ return;
2781
+ }
2782
+ if (deferred) {
2783
+ const written = await port.appendPending(deferred);
2784
+ decision.pendingFact = written.record;
2785
+ decision.waitingSince = written.record.timestamp;
2786
+ }
2787
+ ctx.log(`wave ${k} (${wave.name}): the pull request's approval does not cover it (${covered.reason}), so it waits at its own gate ${gate}`);
2788
+ decision.status = "waiting";
2789
+ decision.approve = approveCommand(spec.name, gate, undefined, digest);
2790
+ return;
2791
+ }
1938
2792
  if (approval === "pr-review") {
1939
2793
  const byReview = await approveByReview(options, { op: spec.name, gate, k, digest, cwd, now, port: ledger, ...(spent ? { spent } : {}) });
1940
2794
  decision.review = byReview.review;
@@ -1954,6 +2808,53 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
1954
2808
  decision.approve = approveCommand(spec.name, gate, undefined, digest, approval === "sealed");
1955
2809
  }
1956
2810
 
2811
+ /**
2812
+ * Under `approval: "pull-request"` (#4550, ruling B): find an approval of the
2813
+ * pull request's gate, under the spec's op, whose change set covers every
2814
+ * member of this wave's plans (`planCoveredBy`, as a resume checks a wave
2815
+ * against the pull request's approval). The newest such approval wins. A
2816
+ * spent one counts for nothing under the spend rule. Needs the plans file's
2817
+ * change set; without one the wave waits at its own gate.
2818
+ */
2819
+ async function approveByPullRequest(
2820
+ options: RunOpWaveOptions,
2821
+ ctx: WaveContext,
2822
+ decision: OpWaveDecision,
2823
+ ledger: GateLedgerPort,
2824
+ ): Promise<{ digest?: string; approvedBy?: string; approvedAt?: string; reason: string }> {
2825
+ const prGate = decision.pullRequestGate;
2826
+ if (!prGate) return { reason: "the spec at base names no approvals.pullRequest.gate" };
2827
+ const fresh = ctx.changeSetDoc;
2828
+ if (!fresh) return { reason: "the plans file carries no change set to check the approval against" };
2829
+ const { planCoveredBy } = await import("../components/pr-run");
2830
+ const read = options.changeSets ?? (async (d: string) => {
2831
+ const { readStoredChangeSet } = await import("../lifecycle/change-set-store");
2832
+ const got = await readStoredChangeSet(d, { cwd: ctx.cwd });
2833
+ return got.status === "found" ? got.document : undefined;
2834
+ });
2835
+ const { resolutions } = await ledger.read(ctx.spec.name);
2836
+ const spent = decision.spend === "base" ? ((await ledger.readApplied?.(ctx.spec.name)) ?? []).filter((a) => a.gate === prGate) : [];
2837
+ const approvals = resolutions.filter((r) => r.gate === prGate && (r.changeSet ?? r.planDigest)).sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1));
2838
+ if (approvals.length === 0) return { reason: `no approval stands at ${prGate}` };
2839
+ let reason = `no approval at ${prGate} covers it`;
2840
+ for (const r of approvals) {
2841
+ const digest = (r.changeSet ?? r.planDigest)!;
2842
+ if (spent.some((a) => a.planDigest === digest && a.approvedAt === r.timestamp)) {
2843
+ reason = `the approval of ${digest} at ${prGate} is spent`;
2844
+ continue;
2845
+ }
2846
+ const approved = await read(digest).catch(() => undefined);
2847
+ if (!approved) {
2848
+ reason = `the change set ${digest} the approval names is not stored`;
2849
+ continue;
2850
+ }
2851
+ const why = fresh.members.map((m) => planCoveredBy(approved, fresh, m.member)).find((w) => w !== undefined);
2852
+ if (why === undefined) return { digest, approvedBy: r.resolvedBy, approvedAt: r.timestamp, reason: "" };
2853
+ reason = why;
2854
+ }
2855
+ return { reason };
2856
+ }
2857
+
1957
2858
  /** The commits after `base` up to `head`, merge commits left out, for the `Requested-by:` trailers on them (#4333). */
1958
2859
  const gitCommitsBetween = (cwd: string) => (base: string, head: string): { sha: string; message: string }[] => {
1959
2860
  try {
@@ -2088,7 +2989,7 @@ async function settleQuorumGate(options: RunOpWaveOptions, ctx: WaveContext, dec
2088
2989
  description: (typeof decision.pending?.description === "string" ? decision.pending.description : undefined) ?? `wave ${k} (${wave.name}): ${members.length} run${members.length === 1 ? "" : "s"}, gate ${policy}, approval ${approval}${held}`,
2089
2990
  now,
2090
2991
  ...(spent ? { spent } : {}),
2091
- fields: { ...decision.pending, approvalMode: approval },
2992
+ fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: approval },
2092
2993
  ...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
2093
2994
  approval: { quorum: rules, mode: "log-only" },
2094
2995
  judge,
@@ -2141,7 +3042,7 @@ async function settlePointGate(options: RunOpWaveOptions, ctx: WaveContext, deci
2141
3042
  planDigest: digest,
2142
3043
  ...(options.now ? { now: options.now } : {}),
2143
3044
  // #3863: the plans file's pending fields and the spec's neverOverMcp, as settleGate passes them.
2144
- fields: { ...decision.pending, approvalMode: decision.approval },
3045
+ fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: decision.approval },
2145
3046
  ...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
2146
3047
  });
2147
3048
  if (check.satisfied) {
@@ -2200,7 +3101,7 @@ async function settleHolds(
2200
3101
  // #3821: the gate decided again, and the wave now waits: the after-gate hooks hear so.
2201
3102
  if (recordPath) await runGateHooks(ctx, decision, recordPath);
2202
3103
  log(`wave ${k} (${wave.name}) is held by ${holds.join(", ")}, and nobody approved ${decision.digest}; nothing applied. Approve: ${decision.approve}`);
2203
- result.exitCode = 3;
3104
+ result.exitCode = CHANT_EXIT.waiting;
2204
3105
  return false;
2205
3106
  }
2206
3107
  log(`wave ${k} (${wave.name}) is held by ${holds.join(", ")}, and ${decision.approvedBy} approved its digest`);
@@ -2208,7 +3109,28 @@ async function settleHolds(
2208
3109
  }
2209
3110
 
2210
3111
  /** How one apply call came out. `applied` with a `problem`: the runs applied, and the wave still fails. `applied-nothing`: the apply said why (#3821). */
2211
- type ApplyCall = { outcome: "applied"; problem?: string } | { outcome: "failed" | "waiting" } | { outcome: "applied-nothing"; said: OpWaveApplyOutcome };
3112
+ type ApplyCall =
3113
+ | { outcome: "applied"; problem?: string }
3114
+ | { outcome: "failed"; applied?: string[] }
3115
+ | { outcome: "waiting" }
3116
+ | { outcome: "applied-nothing"; said: OpWaveApplyOutcome };
3117
+
3118
+ /**
3119
+ * The runs a failed `applyWave` call says it applied (#4291 on op waves):
3120
+ * `{ "applied": [<target>...] }` at `CHANT_APPLY_RUNS_RESULT`. Absent or
3121
+ * unreadable, none did, as before.
3122
+ */
3123
+ function readAppliedRuns(path: string, label: string, log: (line: string) => void): string[] | undefined {
3124
+ if (!existsSync(path)) return undefined;
3125
+ try {
3126
+ const got = JSON.parse(readFileSync(path, "utf-8")) as { applied?: unknown };
3127
+ if (Array.isArray(got?.applied) && got.applied.every((t) => typeof t === "string")) return got.applied as string[];
3128
+ } catch {
3129
+ // Read as absent below.
3130
+ }
3131
+ log(`${label}: CHANT_APPLY_RUNS_RESULT is not { "applied": [<target>...] }, so no run counts as applied`);
3132
+ return undefined;
3133
+ }
2212
3134
 
2213
3135
  /** Read what an apply wrote to `CHANT_APPLY_OUTCOME` (#3821), or undefined when it wrote nothing. A file that says something else is logged and ignored. */
2214
3136
  function readApplyOutcome(path: string, label: string, log: (line: string) => void): OpWaveApplyOutcome | undefined {
@@ -2239,7 +3161,7 @@ async function callApply(
2239
3161
  runs: readonly OpWaveRun[],
2240
3162
  planned: ReadonlyMap<string, OpWaveMember>,
2241
3163
  argv: string[],
2242
- call: { label: string; key: string; runsPath: string },
3164
+ call: { label: string; key: string; runsPath: string; wave?: boolean },
2243
3165
  recordPath?: string,
2244
3166
  ): Promise<ApplyCall> {
2245
3167
  const { spec, k, wave, cwd, exec, log, result } = ctx;
@@ -2248,6 +3170,7 @@ async function callApply(
2248
3170
  const filePath = `${dir}/${call.key}.json`;
2249
3171
  const resultPath = `${dir}/${call.key}-result.json`;
2250
3172
  const outcomePath = `${dir}/${call.key}-outcome.json`;
3173
+ const appliedRunsPath = `${dir}/${call.key}-runs-result.json`;
2251
3174
  const handed: Partial<Record<OpWaveHookMoment, OpWaveHook[]>> = {};
2252
3175
  if (byApply) {
2253
3176
  for (const m of ["before-apply", "after-apply"] as const) if (decision.hooks?.[m]?.length) handed[m] = decision.hooks[m];
@@ -2265,7 +3188,7 @@ async function callApply(
2265
3188
  approved,
2266
3189
  ...(decision.heldBy?.length ? { heldBy: decision.heldBy } : {}),
2267
3190
  runBy: byApply ? "apply" : "chant",
2268
- runs: hookRuns(spec, k, runs, planned),
3191
+ runs: hookRuns(ctx, runs, planned),
2269
3192
  runsFile: call.runsPath,
2270
3193
  hooks: handed,
2271
3194
  outcomes: [...result.hooks],
@@ -2275,9 +3198,12 @@ async function callApply(
2275
3198
  writeFileSync(join(cwd, filePath), JSON.stringify(file, null, 2) + "\n");
2276
3199
  rmSync(join(cwd, resultPath), { force: true });
2277
3200
  rmSync(join(cwd, outcomePath), { force: true });
3201
+ if (call.wave) rmSync(join(cwd, appliedRunsPath), { force: true });
2278
3202
  let code: number;
2279
3203
  try {
2280
- code = exec(argv, cwd, { CHANT_HOOKS: filePath, CHANT_APPLY_OUTCOME: outcomePath, ...(byApply ? { CHANT_HOOKS_RESULT: resultPath } : {}) });
3204
+ const env = { CHANT_HOOKS: filePath, CHANT_APPLY_OUTCOME: outcomePath, ...(call.wave ? { CHANT_APPLY_RUNS_RESULT: appliedRunsPath } : {}), ...(byApply ? { CHANT_HOOKS_RESULT: resultPath } : {}) };
3205
+ // #4588: an applyWave its caller runs in process.
3206
+ code = call.wave && options.waveExec ? await options.waveExec(argv, cwd, env) : exec(argv, cwd, env);
2281
3207
  } catch (err) {
2282
3208
  log(`${call.label}: the apply did not run: ${err instanceof Error ? err.message : String(err)}`);
2283
3209
  code = 127;
@@ -2296,7 +3222,12 @@ async function callApply(
2296
3222
  log(`${call.label}: the apply applied nothing: ${said.outcome}${said.reason ? ` (${said.reason})` : ""}${said.holder ? `, held by run ${said.holder.run}` : ""}`);
2297
3223
  return { outcome: "applied-nothing", said };
2298
3224
  }
2299
- if (!byApply) return { outcome: code === 0 ? "applied" : "failed" };
3225
+ // #4291: a failed applyWave that says which runs applied fails only the others.
3226
+ const failedCall = (): ApplyCall => {
3227
+ const applied = call.wave ? readAppliedRuns(join(cwd, appliedRunsPath), call.label, log) : undefined;
3228
+ return { outcome: "failed", ...(applied?.length ? { applied } : {}) };
3229
+ };
3230
+ if (!byApply) return code === 0 ? { outcome: "applied" } : failedCall();
2300
3231
  let back: OpWaveHooksResult | null = null;
2301
3232
  try {
2302
3233
  back = JSON.parse(readFileSync(join(cwd, resultPath), "utf-8")) as OpWaveHooksResult;
@@ -2319,7 +3250,7 @@ async function callApply(
2319
3250
  }
2320
3251
  const afterFailed = outcomes.find((o) => o.moment === "after-apply" && o.outcome === "failed");
2321
3252
  if (afterFailed) return { outcome: "applied", problem: `${call.label} applied, and then the after-apply hook ${afterFailed.name} failed` };
2322
- if (code !== 0) return { outcome: "failed" };
3253
+ if (code !== 0) return failedCall();
2323
3254
  const skipped = (["before-apply", "after-apply"] as const).filter((m) => handed[m] && !moments.includes(m));
2324
3255
  if (skipped.length > 0) {
2325
3256
  return { outcome: "applied", problem: `${call.label}: the apply exited 0 without running its ${skipped.join(" and ")} hooks (runOpWaveApplyHooks with CHANT_HOOKS), which the spec at base hands it` };
@@ -2363,12 +3294,79 @@ async function applyStage(
2363
3294
  await runGateHooks(ctx, decision, recordPath);
2364
3295
  }
2365
3296
  result.decision = decision;
2366
- result.exitCode = 3;
3297
+ result.exitCode = CHANT_EXIT.waiting;
2367
3298
  return;
2368
3299
  }
2369
3300
  holds.push(...before.holds);
2370
3301
  }
2371
3302
  if (!(await settleHolds(options, ctx, decision, holds, recordPath))) return;
3303
+ // #4552: on the resource grain the wave holds the rows its runs change, before its approval is spent.
3304
+ const lease = spec.step ? await leaseWaveRows(options, ctx, runs) : undefined;
3305
+ if (lease && "failed" in lease) {
3306
+ failed(ctx, lease.failed);
3307
+ return;
3308
+ }
3309
+ if (lease && "outcome" in lease) {
3310
+ log(`wave ${k} (${wave.name}): applied nothing: ${lease.reason}`);
3311
+ result.outcome = lease;
3312
+ result.exitCode = CHANT_EXIT.held;
3313
+ if (recordPath) writeRecord(recordPath, decision, result);
3314
+ return;
3315
+ }
3316
+ try {
3317
+ // #4581: under the lease the grain took, a newer commit that applies the same targets makes this apply stand down.
3318
+ if (await standDownForNewer(options, ctx, decision, runs, recordPath)) return;
3319
+ await applyLeased(options, ctx, decision, runs, planned, byApply, recordPath);
3320
+ } finally {
3321
+ if (lease && !(await lease.release())) log(`wave ${k} (${wave.name}): could not let go of the rows it held; the next apply takes them over once this run is gone`);
3322
+ }
3323
+ }
3324
+
3325
+ /**
3326
+ * Stand down for a newer commit (#4581), when the spec's `standDown` (or
3327
+ * the job's option) asks: a newer commit on the branch whose spec at the
3328
+ * tip applies every one of `runs` in this wave makes the wave apply
3329
+ * nothing, with the `stood-down` outcome and exit 6. The approval is left
3330
+ * unspent. True when it stood down.
3331
+ */
3332
+ async function standDownForNewer(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[], recordPath?: string): Promise<boolean> {
3333
+ const { spec, k, wave, cwd, log, result } = ctx;
3334
+ if (!(options.standDown ?? spec.standDown === true)) return false;
3335
+ const newer = await (options.newerCommit ?? gitOpWaveNewerCommit)(cwd, options.head);
3336
+ if (!newer) return false;
3337
+ const targets = runs.map((r) => r.target);
3338
+ let atTip: OpWavesSpec | null;
3339
+ try {
3340
+ const { text } = (options.show ?? gitShowAtBase)(newer.tip, options.specFile.replace(/^\.\//, "").split("\\").join(posix.sep), cwd);
3341
+ atTip = text === null ? null : parseOpWavesSpec(text, `${options.specFile} at ${newer.tip.slice(0, 12)}`);
3342
+ } catch (err) {
3343
+ log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its spec cannot be read (${err instanceof Error ? err.message : String(err)}), so this job applies`);
3344
+ return false;
3345
+ }
3346
+ if (!tipAppliesTargets(atTip, newer.branch, wave.name, targets)) {
3347
+ log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its wave does not apply every target of this job, so this job applies`);
3348
+ return false;
3349
+ }
3350
+ const reason = opWaveStandDownReason(newer, targets);
3351
+ log(`wave ${k} (${wave.name}): standing down, nothing applied: ${reason}`);
3352
+ result.outcome = { outcome: "stood-down", reason };
3353
+ result.supersededBy = { branch: newer.branch, commit: newer.tip };
3354
+ result.exitCode = CHANT_EXIT.superseded;
3355
+ if (recordPath) writeRecord(recordPath, decision, result);
3356
+ return true;
3357
+ }
3358
+
3359
+ /** {@link applyStage} once its holds are settled and, on the resource grain, its rows held. */
3360
+ async function applyLeased(
3361
+ options: RunOpWaveOptions,
3362
+ ctx: WaveContext,
3363
+ decision: OpWaveDecision,
3364
+ runs: readonly OpWaveRun[],
3365
+ planned: ReadonlyMap<string, OpWaveMember>,
3366
+ byApply: boolean,
3367
+ recordPath?: string,
3368
+ ): Promise<void> {
3369
+ const { spec, k, wave, log, result } = ctx;
2372
3370
  if (!(await spendApproval(options, ctx, decision))) return;
2373
3371
  if (!(await spendOverrides(ctx, decision))) return;
2374
3372
  if (recordPath && (decision.spentAt || decision.overridesSpentAt)) writeRecord(recordPath, decision, result);
@@ -2378,13 +3376,25 @@ async function applyStage(
2378
3376
  if (spec.applyWave) {
2379
3377
  const runsPath = writeRunsFile(ctx, runs, planned, decision.digest);
2380
3378
  const argv = opWaveArgv(spec.applyWave, { op: spec.op, wave: wave.name, runs: runsPath, plans: opWavePlansPath(spec, k) });
2381
- const got = await callApply(options, ctx, decision, runs, planned, argv, { label: `wave ${k} (${wave.name})`, key: "hooks", runsPath }, recordPath);
3379
+ // #4555: one call applies every run, so each run's step spans that call.
3380
+ const startedMs = runs.map((r) => targetStarted(options, k, r.target))[0] ?? Date.now();
3381
+ const got = await callApply(options, ctx, decision, runs, planned, argv, { label: `wave ${k} (${wave.name})`, key: "hooks", runsPath, wave: true }, recordPath);
3382
+ const said = new Set(got.outcome === "failed" ? (got.applied ?? []) : []);
3383
+ const settle = (target: string): "ok" | "failed" | "skipped" => (got.outcome === "applied" || said.has(target) ? "ok" : got.outcome === "failed" ? "failed" : "skipped");
3384
+ for (const r of runs) targetSettled(options, result, k, r.target, startedMs, settle(r.target));
2382
3385
  if (got.outcome === "applied-nothing") nothing = got.said;
2383
3386
  else if (got.outcome === "applied") {
2384
3387
  result.applied.push(...runs.map((r) => r.target));
2385
3388
  if (got.problem) problems.push(got.problem);
2386
3389
  } else if (got.outcome === "waiting") waiting = true;
2387
- else {
3390
+ else if (said.size > 0) {
3391
+ // #4291: the apply said which runs applied, so a failure blocks only what depends on the others.
3392
+ const applied = runs.filter((r) => said.has(r.target)).map((r) => r.target);
3393
+ const failedRuns = runs.filter((r) => !said.has(r.target)).map((r) => r.target);
3394
+ log(`wave ${k} (${wave.name}): apply failed for ${failedRuns.join(", ")}; ${applied.join(", ")} applied`);
3395
+ result.applied.push(...applied);
3396
+ result.failed.push(...failedRuns);
3397
+ } else {
2388
3398
  log(`wave ${k} (${wave.name}): apply failed, so none of ${runs.map((r) => r.target).join(", ")} counts as applied`);
2389
3399
  result.failed.push(...runs.map((r) => r.target));
2390
3400
  }
@@ -2399,11 +3409,38 @@ async function applyStage(
2399
3409
  log(`${run.target}: blocked by ${by}, so not applied`);
2400
3410
  continue;
2401
3411
  }
3412
+ if (spec.step) {
3413
+ // #4545: the run applies through its step, with the plan the gate decided.
3414
+ const plan = ctx.steps?.get(run.target);
3415
+ if (!plan) {
3416
+ log(`${run.target}: this job holds no plan of it to apply`);
3417
+ result.failed.push(run.target);
3418
+ continue;
3419
+ }
3420
+ const registry = await opWaveRegistry(options, ctx.cwd, options.capabilities);
3421
+ const startedMs = targetStarted(options, k, run.target);
3422
+ const got = await applyOpWaveStep({ spec, wave, registry }, run, plan);
3423
+ targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "moved" ? "skipped" : "failed", {
3424
+ ...(got.outcome !== "applied" ? { error: got.reason } : {}),
3425
+ ...(got.facts ? { facts: got.facts } : {}),
3426
+ });
3427
+ if (got.outcome === "applied") result.applied.push(run.target);
3428
+ else if (got.outcome === "moved") {
3429
+ log(`${run.target}: its plan moved since wave ${k} was decided, so it was not applied: ${got.reason}`);
3430
+ result.moved.push(run.target);
3431
+ } else {
3432
+ log(`${run.target}: apply failed: ${got.reason}`);
3433
+ result.failed.push(run.target);
3434
+ }
3435
+ continue;
3436
+ }
2402
3437
  const key = run.target.replace(/[^A-Za-z0-9._-]/g, "_");
2403
3438
  // Under runBy "apply" each run's apply runs its own apply-stage hooks, over a runs file of that run alone.
2404
3439
  const runsPath = byApply ? writeRunsFile(ctx, [run], planned, decision.digest, `.chant/op-waves/${spec.name}/wave-${k}/${key}.runs.json`) : opWaveRunsPath(spec, k);
2405
3440
  const argv = opWaveArgv(spec.apply ?? OP_WAVE_DEFAULT_APPLY, { op: run.op ?? spec.op, target: run.target, wave: wave.name, plan: opWavePlanPath(spec, k, run.target) });
3441
+ const startedMs = targetStarted(options, k, run.target);
2406
3442
  const got = await callApply(options, ctx, decision, [run], planned, argv, { label: run.target, key: `${key}.hooks`, runsPath }, recordPath);
3443
+ targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "failed" ? "failed" : "skipped");
2407
3444
  if (got.outcome === "applied-nothing") {
2408
3445
  nothing = got.said;
2409
3446
  break;
@@ -2421,6 +3458,7 @@ async function applyStage(
2421
3458
  }
2422
3459
  }
2423
3460
  }
3461
+ if (spec.step) await recordStepReleases(options, ctx, decision, runs);
2424
3462
  if (recordPath && byApply) writeRecord(recordPath, decision, result);
2425
3463
  if (nothing) {
2426
3464
  // #3821: no run counts as failed; the wave stops here, or plans again.
@@ -2429,18 +3467,23 @@ async function applyStage(
2429
3467
  return;
2430
3468
  }
2431
3469
  result.outcome = nothing;
2432
- result.exitCode = nothing.outcome === "stood-down" ? 6 : 5;
3470
+ result.exitCode = nothing.outcome === "stood-down" ? CHANT_EXIT.superseded : CHANT_EXIT.held;
2433
3471
  if (recordPath) writeRecord(recordPath, decision, result);
2434
3472
  return;
2435
3473
  }
2436
3474
  if (waiting) {
2437
- result.exitCode = decision.status === "refused" ? refusedExit(decision) : 3;
3475
+ result.exitCode = decision.status === "refused" ? refusedExit(decision) : CHANT_EXIT.waiting;
2438
3476
  return;
2439
3477
  }
2440
3478
  if (result.failed.length > 0) {
2441
3479
  result.exitCode = 1;
2442
3480
  return;
2443
3481
  }
3482
+ // #4545: a run its step refused as moved applied nothing, so the wave exits moved and its after-apply hooks do not run.
3483
+ if (spec.step && result.moved.length > 0) {
3484
+ result.exitCode = CHANT_EXIT.moved;
3485
+ return;
3486
+ }
2444
3487
  if (problems.length > 0) {
2445
3488
  for (const p of problems) log(p);
2446
3489
  result.exitCode = 1;
@@ -2453,6 +3496,48 @@ async function applyStage(
2453
3496
  if (recordPath && result.hooks.length > 0) writeRecord(recordPath, decision, result);
2454
3497
  }
2455
3498
 
3499
+ /**
3500
+ * The release records of the runs this wave applied through its step
3501
+ * (#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.
3503
+ */
3504
+ async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[]): Promise<void> {
3505
+ const { spec, k, wave, log, result } = ctx;
3506
+ if (options.releases === false) return;
3507
+ const port = options.releases ?? (options.gates ? undefined : gitOpWaveReleasePort({ cwd: ctx.cwd }));
3508
+ if (!port) return;
3509
+ const applied = new Set(result.applied);
3510
+ let gitSha = options.head;
3511
+ const requests: OpWaveReleaseRequest[] = [];
3512
+ for (const run of runs) {
3513
+ if (!applied.has(run.target)) continue;
3514
+ const names = opWaveReleaseNames(spec, wave, run);
3515
+ const plan = ctx.steps?.get(run.target);
3516
+ if (!names || !plan) continue;
3517
+ if (gitSha === undefined) {
3518
+ try {
3519
+ gitSha = execFileSync("git", ["rev-parse", "HEAD"], { cwd: ctx.cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
3520
+ } catch {
3521
+ gitSha = "";
3522
+ }
3523
+ }
3524
+ requests.push({ ...names, target: run.target, planDigest: plan.planDigest, ...(gitSha ? { gitSha } : {}), ...(decision.approvedBy ? { approver: decision.approvedBy } : {}) });
3525
+ }
3526
+ if (requests.length === 0) return;
3527
+ let outcomes: OpWaveReleaseOutcome[];
3528
+ try {
3529
+ outcomes = await port.record(requests);
3530
+ } catch (err) {
3531
+ log(`wave ${k} (${wave.name}): applied, and no release record was written: ${err instanceof Error ? err.message : String(err)}`);
3532
+ return;
3533
+ }
3534
+ for (const [i, req] of requests.entries()) {
3535
+ const got = outcomes[i];
3536
+ if (got?.recorded) log(`${req.target}: recorded on the "${got.env}" release ledger as ${got.component} ${got.digest}${got.releaseDigest ? ` under release ${got.releaseDigest}` : ""}`);
3537
+ 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
+ }
3539
+ }
3540
+
2456
3541
  /**
2457
3542
  * Record that the wave applies under its approval (#3784), which spends it:
2458
3543
  * one line in `_gates/<name>/applied.jsonl`, before anything applies, as
@@ -2562,6 +3647,10 @@ export interface RecordHeadPlansOptions {
2562
3647
  now?: string;
2563
3648
  /** Write the record. Default: append to `chant/lifecycle` and push. */
2564
3649
  write?: (plans: HeadPlans) => Promise<void>;
3650
+ /** The capabilities a spec's `step` plans through (#4545). Default: the project's at `cwd`. */
3651
+ capabilities?: CapabilityRegistry;
3652
+ /** How a cost hold's estimator runs (#4545). */
3653
+ holdExec?: GatePolicyExec;
2565
3654
  }
2566
3655
 
2567
3656
  /**
@@ -2589,7 +3678,11 @@ export async function recordOpWaveHeadPlans(options: RecordHeadPlansOptions): Pr
2589
3678
  const last = spec.waves[spec.waves.length - 1]!;
2590
3679
  for (let k = 1; ; k++) {
2591
3680
  const wave = spec.waves[k - 1] ?? last;
2592
- const { members, extras, waves: found } = planRuns({ spec, k, wave, cwd, exec }, wave.runs, wave.discover === true);
3681
+ 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);
3683
+ // #4545: a cost hold's member is in the digest the merged wave decides, so the head's digest carries it too.
3684
+ const cost = spec.holds?.cost ? costVerdictOf(spec.holds.cost, spec, k, members, steps, cwd, options.holdExec).member : undefined;
3685
+ const extras = cost ? [...(planExtras ?? []), cost] : planExtras;
2593
3686
  plans.waves.push({ wave: k, name: wave.name, digest: opWaveSetDigest(spec, members, extras) });
2594
3687
  if (k >= spec.waves.length && !(last.rest && found !== undefined && k < found)) break;
2595
3688
  }