@intentius/chant 0.124.55 → 0.124.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/dist/ci-agent.d.ts.map +1 -1
  2. package/dist/ci-agent.js +1 -2
  3. package/dist/ci-audit/attribution.d.ts +111 -0
  4. package/dist/ci-audit/attribution.d.ts.map +1 -0
  5. package/dist/ci-audit/attribution.js +194 -0
  6. package/dist/ci-audit/audit-log.d.ts +144 -0
  7. package/dist/ci-audit/audit-log.d.ts.map +1 -0
  8. package/dist/ci-audit/audit-log.js +149 -0
  9. package/dist/ci-audit/index.d.ts +12 -0
  10. package/dist/ci-audit/index.d.ts.map +1 -0
  11. package/dist/ci-audit/index.js +11 -0
  12. package/dist/ci-audit/unrecorded.d.ts +74 -0
  13. package/dist/ci-audit/unrecorded.d.ts.map +1 -0
  14. package/dist/ci-audit/unrecorded.js +95 -0
  15. package/dist/ci-audit.d.ts +3 -0
  16. package/dist/ci-audit.d.ts.map +1 -0
  17. package/dist/ci-audit.js +2 -0
  18. package/dist/ci-control.d.ts.map +1 -1
  19. package/dist/ci-control.js +3 -4
  20. package/dist/ci-estate.d.ts +24 -0
  21. package/dist/ci-estate.d.ts.map +1 -1
  22. package/dist/ci-estate.js +1 -2
  23. package/dist/ci-identity.d.ts.map +1 -1
  24. package/dist/ci-identity.js +2 -3
  25. package/dist/ci-job-guard.d.ts +139 -0
  26. package/dist/ci-job-guard.d.ts.map +1 -0
  27. package/dist/ci-job-guard.js +287 -0
  28. package/dist/ci-jobs.d.ts +7 -0
  29. package/dist/ci-jobs.d.ts.map +1 -1
  30. package/dist/ci-jobs.js +7 -0
  31. package/dist/ci-product-words.d.ts +7 -1
  32. package/dist/ci-product-words.d.ts.map +1 -1
  33. package/dist/ci-product-words.js +38 -4
  34. package/dist/ci-product.d.ts +35 -0
  35. package/dist/ci-product.d.ts.map +1 -1
  36. package/dist/ci-product.js +38 -4
  37. package/dist/ci-respond-run.d.ts +73 -0
  38. package/dist/ci-respond-run.d.ts.map +1 -0
  39. package/dist/ci-respond-run.js +247 -0
  40. package/dist/ci-respond.d.ts +189 -0
  41. package/dist/ci-respond.d.ts.map +1 -0
  42. package/dist/ci-respond.js +285 -0
  43. package/dist/cli/handlers/audit-log.d.ts +12 -0
  44. package/dist/cli/handlers/audit-log.d.ts.map +1 -0
  45. package/dist/cli/handlers/audit-log.js +81 -0
  46. package/dist/cli/handlers/build.d.ts +7 -0
  47. package/dist/cli/handlers/build.d.ts.map +1 -1
  48. package/dist/cli/handlers/build.js +81 -0
  49. package/dist/cli/handlers/ci-check-job.d.ts +11 -0
  50. package/dist/cli/handlers/ci-check-job.d.ts.map +1 -0
  51. package/dist/cli/handlers/ci-check-job.js +27 -0
  52. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  53. package/dist/cli/handlers/ci-check.js +38 -9
  54. package/dist/cli/handlers/e2e-safe-run.d.ts +12 -0
  55. package/dist/cli/handlers/e2e-safe-run.d.ts.map +1 -0
  56. package/dist/cli/handlers/e2e-safe-run.js +23 -0
  57. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  58. package/dist/cli/handlers/lifecycle.js +14 -0
  59. package/dist/cli/handlers/pr.d.ts +5 -0
  60. package/dist/cli/handlers/pr.d.ts.map +1 -1
  61. package/dist/cli/handlers/pr.js +346 -36
  62. package/dist/cli/handlers/run-wave.js +89 -1
  63. package/dist/cli/main.d.ts.map +1 -1
  64. package/dist/cli/main.js +56 -2
  65. package/dist/cli/parse-args.d.ts.map +1 -1
  66. package/dist/cli/parse-args.js +107 -0
  67. package/dist/cli/registry.d.ts +38 -0
  68. package/dist/cli/registry.d.ts.map +1 -1
  69. package/dist/components/adoption.d.ts.map +1 -1
  70. package/dist/components/adoption.js +1 -2
  71. package/dist/components/auto-release.d.ts +5 -2
  72. package/dist/components/auto-release.d.ts.map +1 -1
  73. package/dist/components/auto-release.js +9 -4
  74. package/dist/components/capability.d.ts +47 -0
  75. package/dist/components/capability.d.ts.map +1 -1
  76. package/dist/components/capability.js +25 -0
  77. package/dist/components/check-hooks.d.ts +4 -1
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-steps.d.ts +74 -0
  80. package/dist/components/check-steps.d.ts.map +1 -0
  81. package/dist/components/check-steps.js +102 -0
  82. package/dist/components/ci-services.d.ts.map +1 -1
  83. package/dist/components/ci-services.js +1 -2
  84. package/dist/components/deploy-units.d.ts +12 -0
  85. package/dist/components/deploy-units.d.ts.map +1 -1
  86. package/dist/components/deploy-units.js +20 -1
  87. package/dist/components/driver.d.ts +12 -0
  88. package/dist/components/driver.d.ts.map +1 -1
  89. package/dist/components/driver.js +35 -1
  90. package/dist/components/groups.d.ts.map +1 -1
  91. package/dist/components/groups.js +4 -3
  92. package/dist/components/pr-env-ledger.d.ts.map +1 -1
  93. package/dist/components/pr-env-ledger.js +1 -2
  94. package/dist/components/pr-environment.d.ts +1 -1
  95. package/dist/components/pr-environment.d.ts.map +1 -1
  96. package/dist/components/pr-environment.js +1 -1
  97. package/dist/components/pr-pipeline.d.ts +137 -5
  98. package/dist/components/pr-pipeline.d.ts.map +1 -1
  99. package/dist/components/pr-pipeline.js +164 -20
  100. package/dist/components/pr-run.d.ts +8 -0
  101. package/dist/components/pr-run.d.ts.map +1 -1
  102. package/dist/components/pr-run.js +9 -4
  103. package/dist/components/product-pipeline.d.ts +35 -2
  104. package/dist/components/product-pipeline.d.ts.map +1 -1
  105. package/dist/components/product-pipeline.js +24 -5
  106. package/dist/components/row-lease.d.ts +22 -1
  107. package/dist/components/row-lease.d.ts.map +1 -1
  108. package/dist/components/row-lease.js +32 -6
  109. package/dist/components/wave-plan.d.ts +8 -0
  110. package/dist/components/wave-plan.d.ts.map +1 -1
  111. package/dist/components/wave-plan.js +18 -2
  112. package/dist/e2e-harness/bucket.d.ts +21 -0
  113. package/dist/e2e-harness/bucket.d.ts.map +1 -0
  114. package/dist/e2e-harness/bucket.js +61 -0
  115. package/dist/e2e-harness/claim.d.ts +70 -0
  116. package/dist/e2e-harness/claim.d.ts.map +1 -0
  117. package/dist/e2e-harness/claim.js +98 -0
  118. package/dist/e2e-harness/driver.d.ts +64 -0
  119. package/dist/e2e-harness/driver.d.ts.map +1 -0
  120. package/dist/e2e-harness/driver.js +243 -0
  121. package/dist/e2e-harness/forgejo.d.ts +77 -0
  122. package/dist/e2e-harness/forgejo.d.ts.map +1 -0
  123. package/dist/e2e-harness/forgejo.js +205 -0
  124. package/dist/e2e-harness/git.d.ts +32 -0
  125. package/dist/e2e-harness/git.d.ts.map +1 -0
  126. package/dist/e2e-harness/git.js +67 -0
  127. package/dist/e2e-harness/index.d.ts +22 -0
  128. package/dist/e2e-harness/index.d.ts.map +1 -0
  129. package/dist/e2e-harness/index.js +47 -0
  130. package/dist/e2e-harness/jobs.d.ts +8 -0
  131. package/dist/e2e-harness/jobs.d.ts.map +1 -0
  132. package/dist/e2e-harness/jobs.js +34 -0
  133. package/dist/e2e-harness/pins.d.ts +45 -0
  134. package/dist/e2e-harness/pins.d.ts.map +1 -0
  135. package/dist/e2e-harness/pins.js +44 -0
  136. package/dist/e2e-harness/ports.d.ts +113 -0
  137. package/dist/e2e-harness/ports.d.ts.map +1 -0
  138. package/dist/e2e-harness/ports.js +4 -0
  139. package/dist/e2e-harness/reports.d.ts +45 -0
  140. package/dist/e2e-harness/reports.d.ts.map +1 -0
  141. package/dist/e2e-harness/reports.js +57 -0
  142. package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
  143. package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
  144. package/dist/e2e-harness/safe-run-cli.js +43 -0
  145. package/dist/e2e-harness/safe-run.d.ts +61 -0
  146. package/dist/e2e-harness/safe-run.d.ts.map +1 -0
  147. package/dist/e2e-harness/safe-run.js +172 -0
  148. package/dist/e2e-harness/scenario.d.ts +11 -0
  149. package/dist/e2e-harness/scenario.d.ts.map +1 -0
  150. package/dist/e2e-harness/scenario.js +89 -0
  151. package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  152. package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
  153. package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  154. package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  155. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  156. package/dist/e2e-harness/schemas/index.d.ts +191 -0
  157. package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
  158. package/dist/e2e-harness/schemas/index.js +62 -0
  159. package/dist/e2e-harness/stack.d.ts +124 -0
  160. package/dist/e2e-harness/stack.d.ts.map +1 -0
  161. package/dist/e2e-harness/stack.js +207 -0
  162. package/dist/e2e-harness/steps.d.ts +11 -0
  163. package/dist/e2e-harness/steps.d.ts.map +1 -0
  164. package/dist/e2e-harness/steps.js +22 -0
  165. package/dist/e2e-harness.d.ts +3 -0
  166. package/dist/e2e-harness.d.ts.map +1 -0
  167. package/dist/e2e-harness.js +2 -0
  168. package/dist/exit-codes.d.ts +7 -1
  169. package/dist/exit-codes.d.ts.map +1 -1
  170. package/dist/exit-codes.js +7 -1
  171. package/dist/lexicon.d.ts +55 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  174. package/dist/lifecycle/gate-ledger.js +2 -3
  175. package/dist/lifecycle/gated-request.d.ts.map +1 -1
  176. package/dist/lifecycle/gated-request.js +1 -2
  177. package/dist/lifecycle/git.d.ts +39 -3
  178. package/dist/lifecycle/git.d.ts.map +1 -1
  179. package/dist/lifecycle/git.js +223 -15
  180. package/dist/lifecycle/lock-rows.d.ts +23 -0
  181. package/dist/lifecycle/lock-rows.d.ts.map +1 -1
  182. package/dist/lifecycle/lock-rows.js +47 -8
  183. package/dist/lifecycle/query.d.ts.map +1 -1
  184. package/dist/lifecycle/query.js +4 -5
  185. package/dist/lifecycle/release-catalog.d.ts.map +1 -1
  186. package/dist/lifecycle/release-catalog.js +1 -1
  187. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  188. package/dist/lifecycle/release-ledger.js +1 -2
  189. package/dist/lifecycle/release-status.d.ts +20 -0
  190. package/dist/lifecycle/release-status.d.ts.map +1 -1
  191. package/dist/lifecycle/release-status.js +1 -22
  192. package/dist/lifecycle/resource-lock.d.ts +70 -0
  193. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  194. package/dist/lifecycle/resource-lock.js +241 -5
  195. package/dist/lifecycle/wave-plans.d.ts +23 -7
  196. package/dist/lifecycle/wave-plans.d.ts.map +1 -1
  197. package/dist/lifecycle/wave-plans.js +9 -2
  198. package/dist/op/approval-status.d.ts +103 -0
  199. package/dist/op/approval-status.d.ts.map +1 -0
  200. package/dist/op/approval-status.js +197 -0
  201. package/dist/op/gate.js +21 -4
  202. package/dist/op/index.d.ts +1 -1
  203. package/dist/op/index.d.ts.map +1 -1
  204. package/dist/op/index.js +1 -1
  205. package/dist/op/op-waves-capability-spec.d.ts +8 -0
  206. package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
  207. package/dist/op/op-waves-capability-spec.js +21 -0
  208. package/dist/op/op-waves-release-port.js +1 -1
  209. package/dist/op/op-waves-release.d.ts +2 -1
  210. package/dist/op/op-waves-release.d.ts.map +1 -1
  211. package/dist/op/op-waves-release.js +1 -2
  212. package/dist/op/op-waves-run.d.ts +15 -2
  213. package/dist/op/op-waves-run.d.ts.map +1 -1
  214. package/dist/op/op-waves-run.js +195 -31
  215. package/dist/op/op-waves-stand-down.d.ts.map +1 -1
  216. package/dist/op/op-waves-stand-down.js +1 -2
  217. package/dist/op/op-waves.d.ts +53 -0
  218. package/dist/op/op-waves.d.ts.map +1 -1
  219. package/dist/op/op-waves.js +62 -6
  220. package/dist/op/runtime.d.ts +4 -0
  221. package/dist/op/runtime.d.ts.map +1 -1
  222. package/dist/op/runtime.js +2 -3
  223. package/dist/otlp.d.ts.map +1 -1
  224. package/dist/otlp.js +1 -2
  225. package/dist/parallelism.d.ts +17 -0
  226. package/dist/parallelism.d.ts.map +1 -0
  227. package/dist/parallelism.js +33 -0
  228. package/dist/policy-source.d.ts.map +1 -1
  229. package/dist/policy-source.js +1 -2
  230. package/dist/pr-forge.d.ts.map +1 -1
  231. package/dist/pr-forge.js +56 -39
  232. package/dist/pr-loop.d.ts +9 -0
  233. package/dist/pr-loop.d.ts.map +1 -1
  234. package/dist/pr-loop.js +22 -4
  235. package/dist/pr-merge.d.ts +64 -0
  236. package/dist/pr-merge.d.ts.map +1 -0
  237. package/dist/pr-merge.js +78 -0
  238. package/dist/pr-post.d.ts +70 -1
  239. package/dist/pr-post.d.ts.map +1 -1
  240. package/dist/pr-post.js +116 -5
  241. package/dist/pr-report-url.d.ts.map +1 -1
  242. package/dist/pr-report-url.js +1 -2
  243. package/dist/release-floors.d.ts +1 -1
  244. package/dist/release-floors.js +1 -1
  245. package/dist/run-event.d.ts.map +1 -1
  246. package/dist/run-event.js +1 -2
  247. package/dist/scheduled-op-cloud.d.ts +32 -0
  248. package/dist/scheduled-op-cloud.d.ts.map +1 -0
  249. package/dist/scheduled-op-cloud.js +69 -0
  250. package/dist/wave-runtime.mjs +351 -328
  251. package/dist/workspace/ci-lock-grain.d.ts +5 -0
  252. package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
  253. package/dist/workspace/ci-lock-grain.js +1 -7
  254. package/dist/workspace/ci-run.d.ts.map +1 -1
  255. package/dist/workspace/ci-run.js +5 -1
  256. package/dist/workspace/pr-report.schema.json +5 -0
  257. package/package.json +1 -1
  258. package/src/ci-agent.ts +1 -2
  259. package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
  260. package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
  261. package/src/ci-audit/attribution.ts +260 -0
  262. package/src/ci-audit/audit-log.ts +220 -0
  263. package/src/ci-audit/ci-audit.test.ts +175 -0
  264. package/src/ci-audit/index.ts +14 -0
  265. package/src/ci-audit/unrecorded.ts +140 -0
  266. package/src/ci-audit.ts +2 -0
  267. package/src/ci-control.ts +3 -4
  268. package/src/ci-estate.ts +1 -2
  269. package/src/ci-identity-database.test.ts +2 -3
  270. package/src/ci-identity-targets.test.ts +1 -3
  271. package/src/ci-identity.ts +2 -3
  272. package/src/ci-job-guard.test.ts +154 -0
  273. package/src/ci-job-guard.ts +319 -0
  274. package/src/ci-jobs.ts +8 -0
  275. package/src/ci-product-comment-targets.test.ts +45 -0
  276. package/src/ci-product-words.ts +35 -6
  277. package/src/ci-product.ts +55 -4
  278. package/src/ci-respond-run.ts +291 -0
  279. package/src/ci-respond.test.ts +264 -0
  280. package/src/ci-respond.ts +412 -0
  281. package/src/cli/handlers/audit-log.ts +74 -0
  282. package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
  283. package/src/cli/handlers/build.ts +69 -0
  284. package/src/cli/handlers/ci-check-job.test.ts +114 -0
  285. package/src/cli/handlers/ci-check-job.ts +33 -0
  286. package/src/cli/handlers/ci-check.ts +38 -8
  287. package/src/cli/handlers/e2e-safe-run.ts +27 -0
  288. package/src/cli/handlers/lifecycle.ts +13 -0
  289. package/src/cli/handlers/pr-before-merge.test.ts +1 -1
  290. package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
  291. package/src/cli/handlers/pr-endpoint.test.ts +1 -1
  292. package/src/cli/handlers/pr-green.test.ts +1 -1
  293. package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
  294. package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
  295. package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
  296. package/src/cli/handlers/pr-record.test.ts +34 -2
  297. package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
  298. package/src/cli/handlers/pr-waves.test.ts +1 -1
  299. package/src/cli/handlers/pr.test.ts +1 -1
  300. package/src/cli/handlers/pr.ts +311 -32
  301. package/src/cli/handlers/run-wave.ts +79 -1
  302. package/src/cli/main.test.ts +1 -1
  303. package/src/cli/main.ts +56 -2
  304. package/src/cli/parse-args.ts +77 -0
  305. package/src/cli/registry.ts +38 -0
  306. package/src/components/adoption.ts +1 -2
  307. package/src/components/auto-release.test.ts +4 -2
  308. package/src/components/auto-release.ts +9 -5
  309. package/src/components/capability.ts +60 -0
  310. package/src/components/check-hooks.ts +4 -1
  311. package/src/components/check-steps.test.ts +70 -0
  312. package/src/components/check-steps.ts +158 -0
  313. package/src/components/ci-services.ts +1 -2
  314. package/src/components/deploy-units.test.ts +18 -1
  315. package/src/components/deploy-units.ts +26 -1
  316. package/src/components/driver.ts +35 -1
  317. package/src/components/groups.ts +4 -2
  318. package/src/components/plan-flags.test.ts +46 -0
  319. package/src/components/pr-comment-preview-targets.test.ts +34 -0
  320. package/src/components/pr-env-ledger.ts +1 -2
  321. package/src/components/pr-env-run-bundle.test.ts +0 -20
  322. package/src/components/pr-environment.ts +1 -1
  323. package/src/components/pr-pipeline-runners.test.ts +80 -0
  324. package/src/components/pr-pipeline.ts +244 -20
  325. package/src/components/pr-run.ts +17 -6
  326. package/src/components/pr-stale-job.test.ts +34 -0
  327. package/src/components/product-pipeline.ts +50 -8
  328. package/src/components/row-lease.test.ts +61 -1
  329. package/src/components/row-lease.ts +48 -7
  330. package/src/components/wave-plan.ts +18 -2
  331. package/src/e2e-harness/__project__/chant.config.ts +4 -0
  332. package/src/e2e-harness/__project__/src/compose.ts +33 -0
  333. package/src/e2e-harness/bucket.ts +69 -0
  334. package/src/e2e-harness/claim.test.ts +150 -0
  335. package/src/e2e-harness/claim.ts +140 -0
  336. package/src/e2e-harness/driver.test.ts +304 -0
  337. package/src/e2e-harness/driver.ts +294 -0
  338. package/src/e2e-harness/forgejo.ts +267 -0
  339. package/src/e2e-harness/git.ts +96 -0
  340. package/src/e2e-harness/index.ts +49 -0
  341. package/src/e2e-harness/jobs.ts +35 -0
  342. package/src/e2e-harness/pins.ts +52 -0
  343. package/src/e2e-harness/ports.ts +130 -0
  344. package/src/e2e-harness/reports.ts +79 -0
  345. package/src/e2e-harness/safe-run-cli.test.ts +102 -0
  346. package/src/e2e-harness/safe-run-cli.ts +54 -0
  347. package/src/e2e-harness/safe-run.ts +198 -0
  348. package/src/e2e-harness/scenario.ts +89 -0
  349. package/src/e2e-harness/schemas/README.md +62 -0
  350. package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  351. package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
  352. package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  353. package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  354. package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  355. package/src/e2e-harness/schemas/index.ts +220 -0
  356. package/src/e2e-harness/schemas.test.ts +145 -0
  357. package/src/e2e-harness/stack.test.ts +124 -0
  358. package/src/e2e-harness/stack.ts +306 -0
  359. package/src/e2e-harness/steps.ts +30 -0
  360. package/src/e2e-harness.ts +2 -0
  361. package/src/exit-codes.test.ts +3 -2
  362. package/src/exit-codes.ts +7 -1
  363. package/src/gate-decision-bundle.test.ts +0 -2
  364. package/src/lexicon.ts +57 -0
  365. package/src/lifecycle/control-entries-ledger.test.ts +2 -3
  366. package/src/lifecycle/gate-ledger.ts +2 -3
  367. package/src/lifecycle/gated-request.ts +1 -2
  368. package/src/lifecycle/git.test.ts +155 -0
  369. package/src/lifecycle/git.ts +213 -17
  370. package/src/lifecycle/lock-rows.test.ts +6 -1
  371. package/src/lifecycle/lock-rows.ts +58 -7
  372. package/src/lifecycle/query.ts +4 -5
  373. package/src/lifecycle/release-catalog.test.ts +3 -4
  374. package/src/lifecycle/release-catalog.ts +1 -1
  375. package/src/lifecycle/release-ledger.ts +1 -2
  376. package/src/lifecycle/release-status.test.ts +3 -4
  377. package/src/lifecycle/release-status.ts +1 -2
  378. package/src/lifecycle/resource-lock-wait.test.ts +292 -0
  379. package/src/lifecycle/resource-lock.ts +261 -7
  380. package/src/lifecycle/wave-plans.ts +33 -5
  381. package/src/op/approval-status.test.ts +134 -0
  382. package/src/op/approval-status.ts +235 -0
  383. package/src/op/gate-review.test.ts +2 -1
  384. package/src/op/gate.test.ts +7 -5
  385. package/src/op/gate.ts +20 -4
  386. package/src/op/index.ts +2 -0
  387. package/src/op/op-waves-after-plan.test.ts +11 -0
  388. package/src/op/op-waves-capability-spec.ts +20 -0
  389. package/src/op/op-waves-ledger-lock.test.ts +208 -0
  390. package/src/op/op-waves-parallelism.test.ts +89 -0
  391. package/src/op/op-waves-pull-request.test.ts +78 -1
  392. package/src/op/op-waves-release-port.ts +1 -1
  393. package/src/op/op-waves-release.ts +2 -3
  394. package/src/op/op-waves-run.ts +196 -31
  395. package/src/op/op-waves-stand-down.ts +1 -2
  396. package/src/op/op-waves.ts +81 -6
  397. package/src/op/runtime.ts +6 -3
  398. package/src/otlp.ts +1 -2
  399. package/src/parallelism.test.ts +38 -0
  400. package/src/parallelism.ts +33 -0
  401. package/src/policy-source.ts +1 -2
  402. package/src/pr-forge-bundle.test.ts +1 -1
  403. package/src/pr-forge.ts +54 -35
  404. package/src/pr-loop-bundle.test.ts +0 -2
  405. package/src/pr-loop-narrowed.test.ts +63 -0
  406. package/src/pr-loop.ts +30 -4
  407. package/src/pr-merge.test.ts +100 -0
  408. package/src/pr-merge.ts +105 -0
  409. package/src/pr-post-stale.test.ts +163 -0
  410. package/src/pr-post.ts +159 -5
  411. package/src/pr-report-url.ts +1 -2
  412. package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
  413. package/src/release-floors.ts +1 -1
  414. package/src/run-event.ts +1 -2
  415. package/src/scheduled-op-cloud.ts +68 -0
  416. package/src/stage-hooks-bundle.test.ts +0 -2
  417. package/src/workspace/ci-lock-grain.ts +1 -2
  418. package/src/workspace/ci-run.ts +5 -1
  419. package/src/workspace/pr-report.schema.json +5 -0
@@ -34,11 +34,12 @@ import {
34
34
  type CiProductWords,
35
35
  type CiProductWordsInput,
36
36
  } from "../ci-product-words";
37
- import { prCommentLockJobs, prCommentPreviewJob, prLoopJobs, prLoopPostJob, withProductBin, type PrCommentLockJob, type PrCommentPreviewJob, type PrLoopJob, type PrLoopPipelineOptions } from "./pr-pipeline";
37
+ import { prCommentLockJobs, prCommentPreviewJob, prLoopJobs, prLoopPostJob, prLoopRunner, prStaleJob, withProductBin, type PrCommentLockJob, type PrCommentPreviewJob, type PrLoopJob, type PrLoopPipelineOptions } from "./pr-pipeline";
38
38
  import type { DriverComponent } from "./driver";
39
39
  import type { ScheduledOpSpec } from "../lexicon";
40
40
  import type { CiRunner } from "../ci-jobs";
41
41
  import { resolveAgentSpec, type OpAgentSpec } from "../ci-agent";
42
+ import type { CiResponses } from "../ci-respond";
42
43
 
43
44
  /** Where the generator writes a product's waves spec, which chant reads at base (#4550). */
44
45
  export const PRODUCT_WAVES_SPEC_DIR = ".chant/op-waves";
@@ -79,6 +80,19 @@ export interface ProductPipelineOptions extends Omit<PrLoopPipelineOptions, "wor
79
80
  * the merge.
80
81
  */
81
82
  componentWaves?: { components: readonly Pick<DriverComponent, "name" | "dependsOn">[]; waveGate?: string; base?: string };
83
+ /**
84
+ * The responses to pipeline events (#4629, `../ci-respond.ts`): a refused
85
+ * wave's diff and a failed apply's triage, on by default, and the
86
+ * description check, off by default. The apply jobs carry them as
87
+ * `CHANT_RESPOND`, the waves spec as its `respond`.
88
+ */
89
+ respond?: CiResponses;
90
+ /**
91
+ * The decide service the description check asks (#4629): a
92
+ * `decide.backends` entry of chant.config at the target branch, and the
93
+ * pinned model. Needed with `respond.description: "check"`.
94
+ */
95
+ decide?: { backend: string; model: string };
82
96
  }
83
97
 
84
98
  /** The jobs of one product pipeline. */
@@ -94,7 +108,7 @@ export interface ProductPipelineJobs {
94
108
  * `chant/lifecycle` that sets `CHANT_CONTROL_DIR`, so the note marks the
95
109
  * cross-stack edges.
96
110
  */
97
- post: { command: string; env: Record<string, string>; control?: ControlNoteCheckout };
111
+ post: { command: string; env: Record<string, string>; control?: ControlNoteCheckout; runner?: CiRunner };
98
112
  /** The record job, when no waves apply on merge. */
99
113
  record?: PrLoopJob;
100
114
  /** The apply before merge, answering the apply comment, with `applyBeforeMerge`. */
@@ -108,13 +122,20 @@ export interface ProductPipelineJobs {
108
122
  * `/<product> lock` keeps the locks the plan took, `/<product> unlock`
109
123
  * releases them. The forge lexicons render the same jobs.
110
124
  */
111
- locks?: PrCommentLockJob[];
125
+ locks?: Array<PrCommentLockJob & { runner?: CiRunner }>;
112
126
  /**
113
127
  * The comment preview (#4620), with `previewComment`: `/<product> <plan
114
128
  * word>` plans the pull request's head again with a read token, and the
115
129
  * job after it posts the note. The forge lexicons render the same jobs.
116
130
  */
117
- preview?: PrCommentPreviewJob;
131
+ preview?: PrCommentPreviewJob & { noteRunner?: CiRunner };
132
+ /**
133
+ * The stale marking (#4628), with `staleNotes`: the command and values of
134
+ * the job that runs on a push to the target branch and marks each open
135
+ * pull request's note posted against another commit stale. The forge
136
+ * lexicons render the same job, `stale-notes`.
137
+ */
138
+ stale?: { command: string; env: Record<string, string>; runner?: CiRunner };
118
139
  /**
119
140
  * The agent (#4616), with `agent`: the comment it answers, `/<product>
120
141
  * agent <ask>`, and the scheduled Op spec whose generated workflow runs
@@ -189,8 +210,13 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
189
210
  const applyMode: CiProductApplyMode = options.words.applyMode === "before-merge" && options.applyBeforeMerge ? "before-merge" : built;
190
211
  const words = assertProductWords({ ...options.words, applyMode }, { jobs });
191
212
  const { waves: given, wavesSpecFile, member, agent: _agent, componentWaves, ...loop } = options;
213
+ const { respond } = options;
214
+ // #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
192
215
  const prLoop: PrLoopPipelineOptions = { ...loop, words, gate: options.gate ?? words.prGate };
193
216
  const [plan, apply, record] = prLoopJobs(forge, env, prLoop, member);
217
+ // #4625: the jobs with no stage of their own run on the default runner.
218
+ const runnerOfDefault = prLoopRunner(options, "default");
219
+ const defaultRunner: { runner?: CiRunner } = runnerOfDefault !== undefined ? { runner: runnerOfDefault } : {};
194
220
  const comments: Partial<Record<CiProductCommand, string>> = {};
195
221
  for (const c of jobs) {
196
222
  const line = commentLine(words, c);
@@ -198,17 +224,20 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
198
224
  }
199
225
  // #4619: the loop's control target, else the waves spec's.
200
226
  const controlTarget = options.control?.target ?? (given?.control ? opWavesControlTarget(given.control) : undefined);
227
+ const post = prLoopPostJob(forge, env, member, words, { ...(options.staleNotes ? { staleNotes: true } : {}), ...(respond ? { respond } : {}), ...(options.decide ? { decide: options.decide } : {}) });
201
228
  const out: ProductPipelineJobs = {
202
229
  words,
203
230
  plan: plan!,
204
- post: { ...prLoopPostJob(forge, env, member, words), ...(controlTarget ? { control: controlNoteCheckout(forge, controlTarget, words) } : {}) },
231
+ post: { ...post, ...(controlTarget ? { control: controlNoteCheckout(forge, controlTarget, words) } : {}), ...defaultRunner },
205
232
  comments,
206
233
  ...(options.applyBeforeMerge ? { applyBeforeMerge: apply! } : {}),
207
234
  };
208
235
  const locks = prCommentLockJobs(forge, { locks: options.locks, words });
209
- if (locks.length > 0) out.locks = locks;
236
+ if (locks.length > 0) out.locks = locks.map((job) => ({ ...job, ...defaultRunner }));
237
+ const stale = prStaleJob(forge, env, prLoop, member);
238
+ if (stale) out.stale = { ...stale, ...defaultRunner };
210
239
  const preview = prCommentPreviewJob(forge, env, prLoop, member);
211
- if (preview) out.preview = preview;
240
+ if (preview) out.preview = { ...preview, ...(defaultRunner.runner !== undefined ? { noteRunner: defaultRunner.runner } : {}) };
212
241
  // #4616: the agent answers its comment from a workflow of its own, generated from this spec.
213
242
  const agentComment = options.agent ? comments.agent : undefined;
214
243
  if (options.agent && agentComment) {
@@ -221,7 +250,20 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
221
250
  ? componentWavesSpec(componentWaves.components, words, componentWaveSteps({ ...(words.bin ? { bin: words.bin } : {}), env, base: componentWaves.base ?? "HEAD^1", ...(member ? { member } : {}), op, gate: prLoop.gate }), { ...(componentWaves.waveGate ? { gate: componentWaves.waveGate } : {}) })
222
251
  : undefined);
223
252
  if (!spec) return { ...out, record: record! };
224
- const named = productWavesSpec(spec, words);
253
+ const wavesRespond = respond ? Object.fromEntries(Object.entries(respond).filter(([e]) => e !== "description")) : {};
254
+ // #4625: the waves run on the apply runner and with the plan's parallelism, unless the spec names its own.
255
+ const applyRunner = prLoopRunner(options, "apply");
256
+ const named = {
257
+ ...productWavesSpec(
258
+ {
259
+ ...spec,
260
+ ...(spec.runner === undefined && applyRunner !== undefined ? { runner: applyRunner } : {}),
261
+ ...(spec.parallelism === undefined && options.parallelism !== undefined && spec.step !== undefined ? { parallelism: options.parallelism } : {}),
262
+ },
263
+ words,
264
+ ),
265
+ ...(Object.keys(wavesRespond).length > 0 ? { respond: { ...(spec.respond ?? {}), ...wavesRespond } } : {}),
266
+ };
225
267
  const specFile = wavesSpecFile ?? productWavesSpecFile(named.name);
226
268
  return { ...out, waves: { spec: named, specFile, jobs: opWaveJobs(named, specFile, { bin: words.bin }) } };
227
269
  }
@@ -20,7 +20,7 @@ import { planFanOut } from "./fan-out";
20
20
  import { runFanOut } from "./fan-out-run";
21
21
  import { componentSetFanOut, groupFanOut, planAndRunComponentGroup, planComponentGroup, runComponentGroup } from "./groups";
22
22
  import { applyPrSet, approvalOf, decidePrGate, planPrSet, readOnlyLedger, type PrPlanSet } from "./pr-run";
23
- import { ledgerRowLease, leaseCapabilityStep, LockRowsHeldError, isLockRowsHeldError, type RowLeasePort } from "./row-lease";
23
+ import { ledgerRowLease, leaseCapabilityStep, LockRowsHeldError, LockWaitTimeoutError, isLockRowsHeldError, type RowLeasePort } from "./row-lease";
24
24
  import { memoryGateLedgerPort } from "../op/gate";
25
25
  import { computePlanDigest } from "../lifecycle/plan-digest";
26
26
  import { lockGrainBeforePlan, type LockGrain, type LockRow } from "../lifecycle/lock-rows";
@@ -487,4 +487,64 @@ describe("the ledger port", () => {
487
487
  expect(isLockRowsHeldError(err)).toBe(true);
488
488
  expect((err as Error).message).toContain("run 200 (https://forge.example/runs/200)");
489
489
  });
490
+
491
+ test("a waiting take that reaches its deadline throws LockWaitTimeoutError, still a held error, and leaves the queue", async () => {
492
+ const cwd = repo();
493
+ const other = ledgerRowLease("pr-apply", { cwd, holder: { run: "400", at: NOW }, alive: async () => "alive", log: quiet });
494
+ await other.take([row("stack shop/staging")], "staging");
495
+ const mine = ledgerRowLease("pr-apply", { cwd, holder: { run: "500", at: NOW }, alive: async () => "alive", log: quiet, waitSeconds: 0, pollMs: 1 });
496
+ const err = await mine.take([row("stack shop/staging")], "staging", { wait: true }).catch((e: unknown) => e);
497
+ expect(err).toBeInstanceOf(LockWaitTimeoutError);
498
+ expect(isLockRowsHeldError(err)).toBe(true);
499
+ expect((err as Error).message).toMatch(/^staging: LockWaitTimeoutError: waited \d+s for stack shop\/staging of pr-apply/);
500
+ expect((await readLockRows("pr-apply", { cwd })).waiting).toBeUndefined();
501
+ });
502
+ });
503
+
504
+ describe("the ruling for ci-products (2026-10-28): a step on the target or repo grain waits for its row", () => {
505
+ /** A capability on `grain` whose lexicon names the target's row. */
506
+ function targetCap(grain: LockGrain) {
507
+ const registry = new CapabilityRegistry().register({
508
+ kind: "fake-target",
509
+ defaultLockGrain: () => grain,
510
+ targetLockRow: (input: RootInput) => ({ key: `root ${input.root}`, target: input.root, address: input.root }),
511
+ async plan(_ctx: DeployContext, input: RootInput) {
512
+ return { member: input.root, planDigest: "sha256:" + "1".repeat(64) };
513
+ },
514
+ async run() {
515
+ return {};
516
+ },
517
+ } as never);
518
+ return registry.resolve("fake-target");
519
+ }
520
+ function waitingPort() {
521
+ const takes: Array<{ label: string; keys: string[]; wait: boolean }> = [];
522
+ const port: RowLeasePort = {
523
+ async take(rows, label, opts) {
524
+ takes.push({ label, keys: rows.map((r) => r.key), wait: opts?.wait === true });
525
+ return { release: async () => true };
526
+ },
527
+ };
528
+ return { port, takes };
529
+ }
530
+
531
+ test("the target grain takes the root row with a wait, before anything plans", async () => {
532
+ const { port, takes } = waitingPort();
533
+ const leased = await leaseCapabilityStep(targetCap("target"), { env: "prod", component: "net", rowLease: port }, { root: "net" });
534
+ expect(takes).toEqual([{ label: "net", keys: ["root net"], wait: true }]);
535
+ expect(leased.ctx.plans).toBeUndefined();
536
+ });
537
+
538
+ test("the repo grain waits for the repo row", async () => {
539
+ const { port, takes } = waitingPort();
540
+ await leaseCapabilityStep(targetCap("repo"), { env: "prod", component: "net", rowLease: port }, { root: "net" });
541
+ expect(takes).toEqual([{ label: "net", keys: ["repo"], wait: true }]);
542
+ });
543
+
544
+ test("the resource grain takes its rows with no wait, as before", async () => {
545
+ const w = world();
546
+ const { port, takes } = waitingPort();
547
+ await leaseCapabilityStep(w.registry.resolve("fake-res"), { env: "prod", component: "net", rowLease: port, lockGrain: "resource" }, { root: "net" });
548
+ expect(takes).toEqual([{ label: "net", keys: ["row net"], wait: false }]);
549
+ });
490
550
  });
@@ -15,6 +15,13 @@
15
15
  * - A held row fails the step, or every member of the group, with a record
16
16
  * marked `held`, so the command exits 5 (`CHANT_EXIT.held`) and nothing of
17
17
  * that step applied.
18
+ * - A step on the `target` grain whose lexicon names its target's row
19
+ * (`targetLockRow`: a stock Pulumi stack, a Terraform root), or on the
20
+ * `repo` grain, waits for that row in the ledger's queue, oldest commit
21
+ * first, up to `CHANT_LOCK_WAIT` seconds (ruling for ci-products
22
+ * 2026-10-28, "Ledger lock"), and at the deadline fails with
23
+ * {@link LockWaitTimeoutError}, held, exit 5. A step on the resource grain
24
+ * never waits.
18
25
  *
19
26
  * The port ({@link ledgerRowLease}) writes `_locks/rows/<gate>.json` through
20
27
  * ../lifecycle/resource-lock.ts with one holder for the whole run, and
@@ -22,7 +29,7 @@
22
29
  * change one object let go of its row only once both have ended.
23
30
  */
24
31
  import type { LockGrain, LockRow } from "../lifecycle/lock-rows";
25
- import { lockGrainBeforePlan, resolvePlannedLock, sortedLockRows } from "../lifecycle/lock-rows";
32
+ import { lockGrainBeforePlan, queueRowsOf, resolvePlannedLock, sortedLockRows } from "../lifecycle/lock-rows";
26
33
  import type { LockLiveness, LockRowHolder } from "../lifecycle/resource-lock";
27
34
  import type { Capability, CapabilityPlan, DeployContext } from "./capability";
28
35
 
@@ -38,8 +45,10 @@ export interface RowLeasePort {
38
45
  * Lease `rows` for `label` (a component, or a group's components), all or
39
46
  * nothing. Throws {@link LockRowsHeldError} when another live run holds
40
47
  * one, and any other error when the rows file cannot be read or written.
48
+ * With `wait`, waits in the queue for them instead, and throws
49
+ * {@link LockWaitTimeoutError} at the deadline.
41
50
  */
42
- take(rows: readonly LockRow[], label: string): Promise<RowLease>;
51
+ take(rows: readonly LockRow[], label: string, opts?: { wait?: boolean }): Promise<RowLease>;
43
52
  }
44
53
 
45
54
  /** Another live run holds a row this apply changes (#4594), so nothing of it applied. Exit 5. */
@@ -51,6 +60,14 @@ export class LockRowsHeldError extends Error {
51
60
  }
52
61
  }
53
62
 
63
+ /** A wait for a target's row reached its deadline (ruling for ci-products 2026-10-28): nothing of the step applied. Exit 5, as a held row is. */
64
+ export class LockWaitTimeoutError extends LockRowsHeldError {
65
+ constructor(message: string) {
66
+ super(message);
67
+ this.name = "LockWaitTimeoutError";
68
+ }
69
+ }
70
+
54
71
  /** Whether `err` is a held row ({@link LockRowsHeldError}), by its mark, so a copy from another bundle counts too. */
55
72
  export function isLockRowsHeldError(err: unknown): err is LockRowsHeldError {
56
73
  return typeof err === "object" && err !== null && (err as { lockRowsHeld?: unknown }).lockRowsHeld === true;
@@ -66,6 +83,12 @@ export interface LedgerRowLeaseOptions {
66
83
  holder?: LockRowHolder;
67
84
  /** Where the lease's info lines go. Default stderr. */
68
85
  log?: (line: string) => void;
86
+ /** How long a waiting take waits, in seconds. Default `CHANT_LOCK_WAIT`. */
87
+ waitSeconds?: number;
88
+ /** How often a waiting take reads the rows file again, in ms. Default `CHANT_LOCK_POLL` seconds, else 10 s. */
89
+ pollMs?: number;
90
+ /** The commit time that orders this run in the queue. Default: HEAD's in `cwd`. */
91
+ commitAt?: string;
69
92
  }
70
93
 
71
94
  /**
@@ -80,14 +103,26 @@ export function ledgerRowLease(gate: string, opts: LedgerRowLeaseOptions = {}):
80
103
  let holder: LockRowHolder | undefined = opts.holder;
81
104
  const lock = () => import("../lifecycle/resource-lock");
82
105
  return {
83
- async take(rows, label) {
106
+ async take(rows, label, takeOpts) {
84
107
  const wanted = sortedLockRows(rows);
85
108
  if (wanted.length === 0) return NO_LEASE;
86
- const { leaseLockRows, lockRowHolder, releaseLockRows } = await lock();
109
+ const { commitTimeOf, leaseLockRows, lockPollMs, lockRowHolder, lockWaitSeconds, releaseLockRows } = await lock();
87
110
  holder ??= lockRowHolder(process.env);
88
111
  const fresh = wanted.filter((r) => (counts.get(r.key) ?? 0) === 0);
89
112
  if (fresh.length > 0) {
90
- const leased = await leaseLockRows(gate, fresh, { holder, ...(opts.cwd ? { cwd: opts.cwd } : {}), ...(opts.alive ? { alive: opts.alive } : {}) });
113
+ const commitAt = takeOpts?.wait ? (opts.commitAt ?? (await commitTimeOf(holder.sha ?? "HEAD", opts.cwd))) : undefined;
114
+ const wait = takeOpts?.wait
115
+ ? {
116
+ wait: {
117
+ deadline: Date.now() + (opts.waitSeconds ?? lockWaitSeconds(process.env)) * 1000,
118
+ pollMs: opts.pollMs ?? lockPollMs(process.env),
119
+ log: (line: string) => log(`${label}: ${line}`),
120
+ ...(commitAt ? { commitAt } : {}),
121
+ },
122
+ }
123
+ : {};
124
+ const leased = await leaseLockRows(gate, fresh, { holder, ...(opts.cwd ? { cwd: opts.cwd } : {}), ...(opts.alive ? { alive: opts.alive } : {}), ...wait });
125
+ if (!leased.ok && leased.timedOut) throw new LockWaitTimeoutError(`${label}: LockWaitTimeoutError: ${leased.message}, so nothing of it was applied.`);
91
126
  if (!leased.ok) {
92
127
  throw new LockRowsHeldError(
93
128
  `${label}: ${leased.message}, so nothing of it was applied. Apply again once that run ends; a run that is gone, or whose lease is older than CHANT_LOCK_STALE seconds, is taken over.`,
@@ -136,8 +171,14 @@ export async function leaseCapabilityStep(
136
171
  input: unknown,
137
172
  ): Promise<{ ctx: DeployContext; lease: RowLease }> {
138
173
  const port = ctx.rowLease;
139
- if (!port || ctx.plans !== undefined || !capability.plan) return { ctx, lease: NO_LEASE };
140
- if ((await lockGrainBeforePlan(capability, input, ctx.lockGrain)) !== "resource") return { ctx, lease: NO_LEASE };
174
+ if (!port) return { ctx, lease: NO_LEASE };
175
+ const grain = await lockGrainBeforePlan(capability, input, ctx.lockGrain);
176
+ if (grain !== "resource") {
177
+ // The ruling for ci-products (2026-10-28): the target's row (or the repo row), waited for, whether or not a plan was handed in.
178
+ const queue = await queueRowsOf(capability, input, ctx.component, grain);
179
+ return { ctx, lease: queue.length > 0 ? await port.take(queue, ctx.component, { wait: true }) : NO_LEASE };
180
+ }
181
+ if (ctx.plans !== undefined || !capability.plan) return { ctx, lease: NO_LEASE };
141
182
  const planned: CapabilityPlan = await capability.plan(ctx, input as never);
142
183
  const lock = await resolvePlannedLock(capability, input, planned, ctx.lockGrain);
143
184
  const plans = planned.artifact !== undefined ? { [planned.member]: planned.artifact } : undefined;
@@ -29,7 +29,7 @@
29
29
 
30
30
  import { resolvePlannedLock, type PlannedLock } from "../lifecycle/lock-rows";
31
31
  import type { PlanShape } from "./covered-round";
32
- import { assertTargetsAccepted, resolveStepInput, unresolvedWiringSources, type DriverComponent, type DriverPhase, type DriverStep } from "./driver";
32
+ import { assertPlanFlagsAccepted, assertTargetsAccepted, resolveStepInput, unresolvedWiringSources, type DriverComponent, type DriverPhase, type DriverStep } from "./driver";
33
33
  import { componentPlanDigest } from "./gate-plan";
34
34
  import { componentDeployInputs, type ComponentDeployInputs } from "./deploy-inputs";
35
35
  import { computePlanDigest } from "../lifecycle/plan-digest";
@@ -156,12 +156,13 @@ export async function planWaveComponent(
156
156
  const locks: Record<string, PlannedLock> = {};
157
157
  const locations: Record<string, string> = {};
158
158
  assertTargetsAccepted(component, registry, ctx);
159
+ assertPlanFlagsAccepted(component, registry, ctx);
159
160
  for (const step of capabilitySteps(component.deploy)) {
160
161
  const capability = registry.resolve(step.kind);
161
162
  if (!capability.plan) continue;
162
163
  const { kind: _kind, ...rest } = step;
163
164
  const input = resolveStepInput(rest, {}, componentOutputs);
164
- const planned = bindTargets(step.kind, ctx, await capability.plan(planContext(ctx, rest, componentOutputs), input as never));
165
+ const planned = bindPlanFlags(ctx, bindTargets(step.kind, ctx, await capability.plan(planContext(ctx, rest, componentOutputs), input as never)));
165
166
  const member = { member: planned.member, planDigest: planned.planDigest };
166
167
  members.push(member);
167
168
  parts.push(planned.changeSet ?? emptyPart(member));
@@ -257,6 +258,21 @@ export function bindTargets(kind: string, ctx: DeployContext, planned: Capabilit
257
258
  return { ...planned, planDigest, targets: want, ...(changeSet ? { changeSet } : {}) };
258
259
  }
259
260
 
261
+ /**
262
+ * A step's plan made with `ctx.refresh` or `ctx.targetDependents` (#4627),
263
+ * its digest bound to them: the digest over the plan's own digest and the
264
+ * flags, so an approval of a refreshed or widened plan covers no plain one,
265
+ * as {@link bindTargets} binds targets. Without either flag, the plan as it
266
+ * came.
267
+ */
268
+ export function bindPlanFlags(ctx: Pick<DeployContext, "refresh" | "targetDependents">, planned: CapabilityPlan): CapabilityPlan {
269
+ const flags = { ...(ctx.refresh ? { refresh: true } : {}), ...(ctx.targetDependents ? { targetDependents: true } : {}) };
270
+ if (Object.keys(flags).length === 0) return planned;
271
+ const planDigest = computePlanDigest("capability-plan-flags", { plan: planned.planDigest, ...flags });
272
+ const changeSet = planned.changeSet ? { ...planned.changeSet, member: { ...planned.changeSet.member, planDigest } } : undefined;
273
+ return { ...planned, planDigest, ...(changeSet ? { changeSet } : {}) };
274
+ }
275
+
260
276
  /** `next` over `prior`, as a later step's outputs win over an earlier one's in a run. */
261
277
  function mergePlannedOutputs(prior: PlannedOutputs | undefined, next: PlannedOutputs): PlannedOutputs {
262
278
  const known = { ...(prior?.known ?? {}), ...next.known };
@@ -0,0 +1,4 @@
1
+ import type { ChantConfig } from "@intentius/chant";
2
+
3
+ /** The e2e harness's compose project (chant#4587): floci, Forgejo, forgejo-runner, and the sql emulator behind a profile. */
4
+ export default { lexicons: ["docker"] } satisfies ChantConfig;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The e2e harness's compose project (chant#4587), the whole stack:
3
+ * floci, Forgejo and forgejo-runner with the docker executor on one network,
4
+ * and the sql emulator's ClickHouse and Postgres behind the `sql` profile.
5
+ * The services are ../../stack.ts's, and every image is ../../pins.ts's.
6
+ *
7
+ * The project name comes from CHANT_E2E_PROJECT at build time (default
8
+ * chant-e2e) and names the network, the containers and the volumes; pass the
9
+ * same name to `docker compose -p`. Host ports bind to 127.0.0.1 and move
10
+ * with CHANT_E2E_FLOCI_PORT, CHANT_E2E_FORGEJO_PORT, CHANT_E2E_CLICKHOUSE_PORT
11
+ * and CHANT_E2E_POSTGRES_PORT.
12
+ *
13
+ * chant build <this dir>/src --lexicon docker -o compose.yaml
14
+ * docker compose -p chant-e2e -f compose.yaml up -d
15
+ * docker compose -p chant-e2e -f compose.yaml --profile sql up -d
16
+ *
17
+ * A product with its own words or ports writes the same few lines with its
18
+ * own options to harnessStack.
19
+ */
20
+ import { Network, Service, Volume } from "@intentius/chant-lexicon-docker";
21
+ import { harnessStack } from "../../stack";
22
+
23
+ const h = harnessStack({ project: process.env.CHANT_E2E_PROJECT ?? "chant-e2e" });
24
+
25
+ export const harness = new Network(h.network);
26
+ export const forgejoData = new Volume(h.volumes.forgejoData);
27
+ export const runnerData = new Volume(h.volumes.runnerData);
28
+
29
+ export const floci = new Service(h.services.floci);
30
+ export const forgejo = new Service(h.services.forgejo);
31
+ export const forgejoRunner = new Service(h.services.forgejoRunner);
32
+ export const clickhouse = new Service(h.services.clickhouse);
33
+ export const postgres = new Service(h.services.postgres);
@@ -0,0 +1,69 @@
1
+ /**
2
+ * A bucket, for real: one bucket in the harness's floci, path-style S3 over
3
+ * http (chant#4587, from the fan-out demo's lib/bucket.ts). floci takes
4
+ * unsigned requests, so the driver needs no AWS CLI on the host. chant's
5
+ * reports under `--report-url` are read from here.
6
+ */
7
+ import type { Bucket } from "./ports";
8
+
9
+ const TIMEOUT_MS = 30_000;
10
+
11
+ export class FlociBucket implements Bucket {
12
+ /** `endpoint` is floci as the driver reaches it, http://localhost:<port>. */
13
+ constructor(
14
+ private readonly endpoint: string,
15
+ private readonly bucket: string,
16
+ ) {}
17
+
18
+ private url(key = ""): string {
19
+ return `${this.endpoint.replace(/\/$/, "")}/${this.bucket}${key ? `/${key.split("/").map(encodeURIComponent).join("/")}` : ""}`;
20
+ }
21
+
22
+ /** The bucket itself. An existing one is kept. */
23
+ async create(): Promise<void> {
24
+ const res = await fetch(this.url(), { method: "PUT", signal: AbortSignal.timeout(TIMEOUT_MS) });
25
+ if (!res.ok && res.status !== 409) throw new Error(`floci PUT ${this.bucket} answered ${res.status}`);
26
+ }
27
+
28
+ async get(key: string): Promise<string | null> {
29
+ const res = await fetch(this.url(key), { signal: AbortSignal.timeout(TIMEOUT_MS) });
30
+ if (res.status === 404 || res.status === 403) return null;
31
+ if (!res.ok) throw new Error(`floci GET ${key} answered ${res.status}`);
32
+ return res.text();
33
+ }
34
+
35
+ async put(key: string, body: string, contentType: string): Promise<void> {
36
+ const res = await fetch(this.url(key), {
37
+ method: "PUT",
38
+ headers: { "content-type": contentType },
39
+ body,
40
+ signal: AbortSignal.timeout(TIMEOUT_MS),
41
+ });
42
+ if (!res.ok) throw new Error(`floci PUT ${key} answered ${res.status}`);
43
+ }
44
+
45
+ async list(prefix: string): Promise<string[]> {
46
+ const keys: string[] = [];
47
+ let token: string | undefined;
48
+ for (;;) {
49
+ const q = new URLSearchParams({ "list-type": "2", prefix, ...(token ? { "continuation-token": token } : {}) });
50
+ const res = await fetch(`${this.url()}?${q.toString()}`, { signal: AbortSignal.timeout(TIMEOUT_MS) });
51
+ if (!res.ok) throw new Error(`floci list ${prefix} answered ${res.status}`);
52
+ const xml = await res.text();
53
+ for (const m of xml.matchAll(/<Key>([^<]*)<\/Key>/g)) keys.push(decodeXml(m[1]!));
54
+ const next = /<NextContinuationToken>([^<]*)<\/NextContinuationToken>/.exec(xml)?.[1];
55
+ if (!next || !/<IsTruncated>true<\/IsTruncated>/.test(xml)) break;
56
+ token = decodeXml(next);
57
+ }
58
+ return keys;
59
+ }
60
+
61
+ async delete(key: string): Promise<void> {
62
+ const res = await fetch(this.url(key), { method: "DELETE", signal: AbortSignal.timeout(TIMEOUT_MS) });
63
+ if (!res.ok && res.status !== 404) throw new Error(`floci DELETE ${key} answered ${res.status}`);
64
+ }
65
+ }
66
+
67
+ function decodeXml(s: string): string {
68
+ return s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
69
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The claim row protocol and the no-real-cloud wrapper (chant#4587): a row
3
+ * from a run's verdicts, the run as an e2e-claim ledger record (#4551), the
4
+ * per-product render, the engine-version rule, and recording refused
5
+ * without a CLEAN scan. The wrapper's own runs are `node -e` one-liners.
6
+ */
7
+ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
8
+ import { tmpdir } from "node:os";
9
+ import { join } from "node:path";
10
+ import { afterAll, describe, expect, test } from "vitest";
11
+ import type { OpRunRecord, OpRunRecordInput } from "../op/runtime";
12
+ import { CLAIM_OP, claimRow, claimRowsOf, claimRunRecordInput, renderClaims, rowCountsFor } from "./claim";
13
+ import type { ArmRun, ClaimRun } from "./driver";
14
+ import { FLOCI_DIGEST } from "./pins";
15
+ import { SafeRun, backendIsLocal, realCloudHits, recordClaimRow, safeRunEnv } from "./safe-run";
16
+ import type { ClaimRow } from "./schemas/index";
17
+
18
+ const tmp = mkdtempSync(join(tmpdir(), "chant-e2e-claim-test-"));
19
+ afterAll(() => rmSync(tmp, { recursive: true, force: true }));
20
+
21
+ const COMMIT = "e962b2c0000000000000000000000000000000aa";
22
+ const scenario = { id: "tg-estate-overlap", product: "terragucci", claim: "choudoufu/rows-overlap" };
23
+
24
+ const arm = (a: "plain" | "break", outcome: ArmRun["outcome"]): ArmRun => ({
25
+ scenario: scenario.id,
26
+ arm: a,
27
+ outcome,
28
+ started: a === "plain" ? "2026-10-28T10:00:00.000Z" : "2026-10-28T10:05:00.000Z",
29
+ ended: a === "plain" ? "2026-10-28T10:04:00.000Z" : "2026-10-28T10:09:00.000Z",
30
+ steps: [
31
+ { id: "one", do: "open", pull: 1 },
32
+ ...(outcome === "held" ? [] : [{ id: "one-apply", do: "apply" as const, stopped: { outcome: outcome as "broke", reason: "a is failed, not applied" } }]),
33
+ ],
34
+ });
35
+
36
+ const run: ClaimRun = { plain: arm("plain", "held"), break: arm("break", "broke"), verdicts: { plain: "pass", break: "caught" } };
37
+
38
+ const rowAt = (date: string, over: Partial<Parameters<typeof claimRow>[0]> = {}): ClaimRow =>
39
+ claimRow({ scenario, productCommit: COMMIT, engine: { binary: "choudoufu", version: "0.31.0" }, verdicts: run.verdicts, at: new Date(`${date}T10:09:00Z`), ...over });
40
+
41
+ const record = (input: OpRunRecordInput, id: string): OpRunRecord => ({ version: 1, id, ...input });
42
+
43
+ describe("the claim row", () => {
44
+ test("names the scenario's product and claim, the run's date and the harness's floci pin", () => {
45
+ const r = rowAt("2026-10-28");
46
+ expect(r).toMatchObject({ product: "terragucci", scenario: "tg-estate-overlap", claim: "choudoufu/rows-overlap", date: "2026-10-28", floci: FLOCI_DIGEST, plain: "pass", break: "caught", safeRun: "CLEAN" });
47
+ expect(() => rowAt("2026-10-28", { productCommit: "e962b2c" })).toThrow(/not e2e-claim-row\/v1/);
48
+ });
49
+
50
+ test("is the claim outcome of an e2e-claim run record, one phase per arm", () => {
51
+ const input = claimRunRecordInput({ row: rowAt("2026-10-28"), run, env: "local", gitSha: COMMIT });
52
+ expect(input.op).toBe(CLAIM_OP);
53
+ expect(input.status).toBe("ok");
54
+ expect(input.labels).toEqual({ Product: "terragucci", Scenario: "tg-estate-overlap", Claim: "choudoufu/rows-overlap" });
55
+ expect(input.started).toBe(run.plain.started);
56
+ expect(input.ended).toBe(run.break.ended);
57
+ expect(input.phases.map((p) => [p.name, p.status])).toEqual([
58
+ ["plain", "ok"],
59
+ ["break", "fail"],
60
+ ]);
61
+ expect(input.phases[1]!.steps.at(-1)).toMatchObject({ fn: "apply:one-apply", status: "fail", error: "broke: a is failed, not applied" });
62
+ expect(input.outcomes.claim).toEqual(rowAt("2026-10-28"));
63
+
64
+ const missed = claimRunRecordInput({ row: { ...rowAt("2026-10-28"), break: "missed" }, run });
65
+ expect(missed.status).toBe("fail");
66
+ });
67
+
68
+ test("renders a product's newest row per scenario and claim, from the ledger's records", () => {
69
+ const old = rowAt("2026-10-20", { verdicts: { plain: "fail", break: "caught" } });
70
+ const now = rowAt("2026-10-28");
71
+ const other = claimRow({ scenario: { ...scenario, id: "tg-migrate", claim: "choudoufu/7" }, productCommit: COMMIT, engine: { binary: "choudoufu", version: "0.31.0" }, verdicts: run.verdicts, at: new Date("2026-10-27T00:00:00Z") });
72
+ const foreign = claimRow({ scenario: { ...scenario, product: "plywood", id: "pw-disjoint" }, productCommit: COMMIT, engine: { binary: "plunge", version: "0.9.0" }, verdicts: run.verdicts, at: new Date("2026-10-27T00:00:00Z") });
73
+ const records = [
74
+ record({ ...claimRunRecordInput({ row: now, run }), ended: "2026-10-28T10:09:00.000Z" }, "c"),
75
+ record({ ...claimRunRecordInput({ row: old, run }), ended: "2026-10-20T10:09:00.000Z" }, "a"),
76
+ record({ ...claimRunRecordInput({ row: other, run }), ended: "2026-10-27T00:00:00.000Z" }, "b"),
77
+ record({ ...claimRunRecordInput({ row: foreign, run }), ended: "2026-10-27T00:00:00.000Z" }, "d"),
78
+ record({ op: "pr-apply", env: "local", started: "", ended: "2026-10-29T00:00:00.000Z", status: "ok", labels: {}, outcomes: { claim: now }, phases: [] }, "e"),
79
+ record({ op: CLAIM_OP, env: "local", started: "", ended: "2026-10-29T00:00:00.000Z", status: "ok", labels: {}, outcomes: { claim: { not: "a row" } }, phases: [] }, "f"),
80
+ ];
81
+ const rows = claimRowsOf(records);
82
+ expect(rows).toHaveLength(4);
83
+ const doc = renderClaims("terragucci", rows);
84
+ expect(doc.product).toBe("terragucci");
85
+ expect(doc.rows.map((r) => [r.scenario, r.date, r.plain])).toEqual([
86
+ ["tg-estate-overlap", "2026-10-28", "pass"],
87
+ ["tg-migrate", "2026-10-27", "pass"],
88
+ ]);
89
+ });
90
+
91
+ test("counts for an engine claim only at the version the row ran, and only when it holds", () => {
92
+ const r = rowAt("2026-10-28");
93
+ expect(rowCountsFor(r, { binary: "choudoufu", version: "v0.31.0" })).toBe(true);
94
+ expect(rowCountsFor(r, { binary: "choudoufu", version: "0.28.0" })).toBe(false);
95
+ expect(rowCountsFor(r, { binary: "plunge", version: "0.31.0" })).toBe(false);
96
+ expect(rowCountsFor({ ...r, break: "missed" }, { binary: "choudoufu", version: "0.31.0" })).toBe(false);
97
+ });
98
+ });
99
+
100
+ describe("the no-real-cloud wrapper", () => {
101
+ test("scrubs every cloud variable and sets floci's test keys, empty config and a file backend", () => {
102
+ const env = safeRunEnv(
103
+ { scratch: join(tmp, "env"), extra: { BREAK: "1" } },
104
+ { PATH: "/usr/bin", AWS_PROFILE: "prod", AWS_SESSION_TOKEN: "x", GOOGLE_APPLICATION_CREDENTIALS: "/k.json", ARM_CLIENT_SECRET: "s", CLOUDSDK_CORE_PROJECT: "p", PULUMI_ACCESS_TOKEN: "pul-x" },
105
+ );
106
+ expect(env.PATH).toBe("/usr/bin");
107
+ expect(env.BREAK).toBe("1");
108
+ for (const k of ["AWS_PROFILE", "AWS_SESSION_TOKEN", "GOOGLE_APPLICATION_CREDENTIALS", "ARM_CLIENT_SECRET", "CLOUDSDK_CORE_PROJECT", "PULUMI_ACCESS_TOKEN"]) expect(env[k], k).toBeUndefined();
109
+ expect(env).toMatchObject({ AWS_ACCESS_KEY_ID: "test", AWS_SECRET_ACCESS_KEY: "test", AWS_REGION: "us-east-1", GCE_METADATA_HOST: "127.0.0.1:9", PULUMI_SKIP_UPDATE_CHECK: "true" });
110
+ expect(env.PULUMI_BACKEND_URL).toMatch(/^file:\/\//);
111
+ expect(readFileSync(env.AWS_SHARED_CREDENTIALS_FILE!, "utf8")).toBe("");
112
+ expect(env.CLOUDSDK_CONFIG!.startsWith(join(tmp, "env"))).toBe(true);
113
+ });
114
+
115
+ test("refuses a credentials file and a backend that is not local", () => {
116
+ expect(() => safeRunEnv({ scratch: join(tmp, "x"), extra: { GOOGLE_APPLICATION_CREDENTIALS: "/k.json" } }, {})).toThrow(/refused/);
117
+ expect(() => safeRunEnv({ scratch: join(tmp, "x") }, { PULUMI_BACKEND_URL: "https://api.pulumi.com" })).toThrow(/not a local backend/);
118
+ expect(safeRunEnv({ scratch: join(tmp, "x") }, { PULUMI_BACKEND_URL: "file:///tmp/s" }).PULUMI_BACKEND_URL).toBe("file:///tmp/s");
119
+ expect(backendIsLocal("plunge+s3://b?endpoint=http://127.0.0.1:4566")).toBe(true);
120
+ expect(backendIsLocal("plunge+s3://b?region=us-east-1")).toBe(false);
121
+ });
122
+
123
+ test("finds what a real cloud says to a fake credential, and nothing an emulator says", () => {
124
+ expect(realCloudHits("ok\nAn error occurred (InvalidClientTokenId) when calling GetCallerIdentity\n")).toEqual(["log:2:An error occurred (InvalidClientTokenId) when calling GetCallerIdentity"]);
125
+ expect(realCloudHits("401 Unauthorized from https://sts.amazonaws.com/")).toHaveLength(1);
126
+ expect(realCloudHits("401 from http://floci:4566/\nstack applied in 4012ms")).toEqual([]);
127
+ });
128
+
129
+ test("a run whose log shows a real cloud is not recorded; a CLEAN one is, as an e2e-claim record", async () => {
130
+ const dirty = new SafeRun({ scratch: join(tmp, "dirty") });
131
+ expect(await dirty.run([process.execPath, "-e", "console.log('UnrecognizedClientException: The security token included in the request is invalid')"])).toBe(0);
132
+ const v = dirty.scan();
133
+ expect(v.verdict).toBe("REAL-CLOUD");
134
+ const appended: OpRunRecordInput[] = [];
135
+ await expect(recordClaimRow({ row: rowAt("2026-10-28"), run, verdict: v, append: async (i) => void appended.push(i) })).rejects.toThrow(/refusing to record tg-estate-overlap/);
136
+ expect(appended).toEqual([]);
137
+
138
+ const clean = new SafeRun({ scratch: join(tmp, "clean"), scan: [join(tmp, "clean")] });
139
+ expect(await clean.run([process.execPath, "-e", "process.exit(3)"])).toBe(3);
140
+ expect(await clean.outOfBand().run([process.execPath, "-e", "console.log(process.env.AWS_ACCESS_KEY_ID)"])).toBe(0);
141
+ expect(readFileSync(clean.logFile, "utf8")).toContain("\ntest\n");
142
+ const ok = clean.scan();
143
+ expect(ok).toEqual({ verdict: "CLEAN" });
144
+ await recordClaimRow({ row: rowAt("2026-10-28"), run, verdict: ok, append: async (i) => void appended.push(i) });
145
+ expect(appended.map((a) => a.op)).toEqual([CLAIM_OP]);
146
+
147
+ const missing = new SafeRun({ scratch: join(tmp, "missing"), scan: [join(tmp, "no-such-dir")] });
148
+ expect(missing.scan().verdict).toBe("REAL-CLOUD");
149
+ });
150
+ });