@intentius/chant 0.124.55 → 0.124.56

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 (370) 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 +12 -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 -3
  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/pr.d.ts +5 -0
  58. package/dist/cli/handlers/pr.d.ts.map +1 -1
  59. package/dist/cli/handlers/pr.js +259 -4
  60. package/dist/cli/handlers/run-wave.js +89 -1
  61. package/dist/cli/main.d.ts.map +1 -1
  62. package/dist/cli/main.js +56 -2
  63. package/dist/cli/parse-args.d.ts.map +1 -1
  64. package/dist/cli/parse-args.js +107 -0
  65. package/dist/cli/registry.d.ts +38 -0
  66. package/dist/cli/registry.d.ts.map +1 -1
  67. package/dist/components/adoption.d.ts.map +1 -1
  68. package/dist/components/adoption.js +1 -2
  69. package/dist/components/capability.d.ts +37 -0
  70. package/dist/components/capability.d.ts.map +1 -1
  71. package/dist/components/capability.js +25 -0
  72. package/dist/components/check-hooks.d.ts +4 -1
  73. package/dist/components/check-hooks.d.ts.map +1 -1
  74. package/dist/components/check-steps.d.ts +74 -0
  75. package/dist/components/check-steps.d.ts.map +1 -0
  76. package/dist/components/check-steps.js +102 -0
  77. package/dist/components/ci-services.d.ts.map +1 -1
  78. package/dist/components/ci-services.js +1 -2
  79. package/dist/components/driver.d.ts +12 -0
  80. package/dist/components/driver.d.ts.map +1 -1
  81. package/dist/components/driver.js +35 -1
  82. package/dist/components/groups.d.ts.map +1 -1
  83. package/dist/components/groups.js +4 -3
  84. package/dist/components/pr-env-ledger.d.ts.map +1 -1
  85. package/dist/components/pr-env-ledger.js +1 -2
  86. package/dist/components/pr-environment.d.ts +1 -1
  87. package/dist/components/pr-environment.d.ts.map +1 -1
  88. package/dist/components/pr-environment.js +1 -1
  89. package/dist/components/pr-pipeline.d.ts +129 -3
  90. package/dist/components/pr-pipeline.d.ts.map +1 -1
  91. package/dist/components/pr-pipeline.js +153 -17
  92. package/dist/components/pr-run.d.ts +8 -0
  93. package/dist/components/pr-run.d.ts.map +1 -1
  94. package/dist/components/pr-run.js +9 -4
  95. package/dist/components/product-pipeline.d.ts +35 -2
  96. package/dist/components/product-pipeline.d.ts.map +1 -1
  97. package/dist/components/product-pipeline.js +24 -5
  98. package/dist/components/wave-plan.d.ts +8 -0
  99. package/dist/components/wave-plan.d.ts.map +1 -1
  100. package/dist/components/wave-plan.js +18 -2
  101. package/dist/e2e-harness/bucket.d.ts +21 -0
  102. package/dist/e2e-harness/bucket.d.ts.map +1 -0
  103. package/dist/e2e-harness/bucket.js +61 -0
  104. package/dist/e2e-harness/claim.d.ts +70 -0
  105. package/dist/e2e-harness/claim.d.ts.map +1 -0
  106. package/dist/e2e-harness/claim.js +98 -0
  107. package/dist/e2e-harness/driver.d.ts +64 -0
  108. package/dist/e2e-harness/driver.d.ts.map +1 -0
  109. package/dist/e2e-harness/driver.js +243 -0
  110. package/dist/e2e-harness/forgejo.d.ts +77 -0
  111. package/dist/e2e-harness/forgejo.d.ts.map +1 -0
  112. package/dist/e2e-harness/forgejo.js +205 -0
  113. package/dist/e2e-harness/git.d.ts +32 -0
  114. package/dist/e2e-harness/git.d.ts.map +1 -0
  115. package/dist/e2e-harness/git.js +67 -0
  116. package/dist/e2e-harness/index.d.ts +22 -0
  117. package/dist/e2e-harness/index.d.ts.map +1 -0
  118. package/dist/e2e-harness/index.js +48 -0
  119. package/dist/e2e-harness/jobs.d.ts +8 -0
  120. package/dist/e2e-harness/jobs.d.ts.map +1 -0
  121. package/dist/e2e-harness/jobs.js +34 -0
  122. package/dist/e2e-harness/pins.d.ts +45 -0
  123. package/dist/e2e-harness/pins.d.ts.map +1 -0
  124. package/dist/e2e-harness/pins.js +44 -0
  125. package/dist/e2e-harness/ports.d.ts +113 -0
  126. package/dist/e2e-harness/ports.d.ts.map +1 -0
  127. package/dist/e2e-harness/ports.js +4 -0
  128. package/dist/e2e-harness/reports.d.ts +45 -0
  129. package/dist/e2e-harness/reports.d.ts.map +1 -0
  130. package/dist/e2e-harness/reports.js +57 -0
  131. package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
  132. package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
  133. package/dist/e2e-harness/safe-run-cli.js +43 -0
  134. package/dist/e2e-harness/safe-run.d.ts +61 -0
  135. package/dist/e2e-harness/safe-run.d.ts.map +1 -0
  136. package/dist/e2e-harness/safe-run.js +172 -0
  137. package/dist/e2e-harness/scenario.d.ts +11 -0
  138. package/dist/e2e-harness/scenario.d.ts.map +1 -0
  139. package/dist/e2e-harness/scenario.js +89 -0
  140. package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  141. package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
  142. package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  143. package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  144. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  145. package/dist/e2e-harness/schemas/index.d.ts +191 -0
  146. package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
  147. package/dist/e2e-harness/schemas/index.js +62 -0
  148. package/dist/e2e-harness/stack.d.ts +124 -0
  149. package/dist/e2e-harness/stack.d.ts.map +1 -0
  150. package/dist/e2e-harness/stack.js +207 -0
  151. package/dist/e2e-harness/steps.d.ts +11 -0
  152. package/dist/e2e-harness/steps.d.ts.map +1 -0
  153. package/dist/e2e-harness/steps.js +22 -0
  154. package/dist/e2e-harness.d.ts +3 -0
  155. package/dist/e2e-harness.d.ts.map +1 -0
  156. package/dist/e2e-harness.js +2 -0
  157. package/dist/exit-codes.d.ts +7 -1
  158. package/dist/exit-codes.d.ts.map +1 -1
  159. package/dist/exit-codes.js +7 -1
  160. package/dist/lexicon.d.ts +46 -0
  161. package/dist/lexicon.d.ts.map +1 -1
  162. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  163. package/dist/lifecycle/gate-ledger.js +2 -3
  164. package/dist/lifecycle/gated-request.d.ts.map +1 -1
  165. package/dist/lifecycle/gated-request.js +1 -2
  166. package/dist/lifecycle/query.d.ts.map +1 -1
  167. package/dist/lifecycle/query.js +4 -5
  168. package/dist/lifecycle/release-catalog.d.ts.map +1 -1
  169. package/dist/lifecycle/release-catalog.js +1 -1
  170. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  171. package/dist/lifecycle/release-ledger.js +1 -2
  172. package/dist/lifecycle/release-status.d.ts +20 -0
  173. package/dist/lifecycle/release-status.d.ts.map +1 -1
  174. package/dist/lifecycle/release-status.js +1 -22
  175. package/dist/lifecycle/wave-plans.d.ts +23 -7
  176. package/dist/lifecycle/wave-plans.d.ts.map +1 -1
  177. package/dist/lifecycle/wave-plans.js +9 -2
  178. package/dist/op/approval-status.d.ts +103 -0
  179. package/dist/op/approval-status.d.ts.map +1 -0
  180. package/dist/op/approval-status.js +197 -0
  181. package/dist/op/index.d.ts +1 -1
  182. package/dist/op/index.d.ts.map +1 -1
  183. package/dist/op/index.js +1 -1
  184. package/dist/op/op-waves-capability-spec.d.ts +8 -0
  185. package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
  186. package/dist/op/op-waves-capability-spec.js +21 -0
  187. package/dist/op/op-waves-release.d.ts.map +1 -1
  188. package/dist/op/op-waves-release.js +1 -2
  189. package/dist/op/op-waves-run.d.ts +7 -2
  190. package/dist/op/op-waves-run.d.ts.map +1 -1
  191. package/dist/op/op-waves-run.js +96 -4
  192. package/dist/op/op-waves-stand-down.d.ts.map +1 -1
  193. package/dist/op/op-waves-stand-down.js +1 -2
  194. package/dist/op/op-waves.d.ts +35 -0
  195. package/dist/op/op-waves.d.ts.map +1 -1
  196. package/dist/op/op-waves.js +46 -6
  197. package/dist/op/runtime.d.ts +4 -0
  198. package/dist/op/runtime.d.ts.map +1 -1
  199. package/dist/op/runtime.js +2 -3
  200. package/dist/otlp.d.ts.map +1 -1
  201. package/dist/otlp.js +1 -2
  202. package/dist/parallelism.d.ts +17 -0
  203. package/dist/parallelism.d.ts.map +1 -0
  204. package/dist/parallelism.js +33 -0
  205. package/dist/policy-source.d.ts.map +1 -1
  206. package/dist/policy-source.js +1 -2
  207. package/dist/pr-forge.d.ts.map +1 -1
  208. package/dist/pr-forge.js +56 -39
  209. package/dist/pr-loop.d.ts +9 -0
  210. package/dist/pr-loop.d.ts.map +1 -1
  211. package/dist/pr-loop.js +22 -3
  212. package/dist/pr-merge.d.ts +64 -0
  213. package/dist/pr-merge.d.ts.map +1 -0
  214. package/dist/pr-merge.js +78 -0
  215. package/dist/pr-post.d.ts +70 -1
  216. package/dist/pr-post.d.ts.map +1 -1
  217. package/dist/pr-post.js +116 -5
  218. package/dist/pr-report-url.d.ts.map +1 -1
  219. package/dist/pr-report-url.js +1 -2
  220. package/dist/release-floors.d.ts +1 -1
  221. package/dist/release-floors.js +1 -1
  222. package/dist/run-event.d.ts.map +1 -1
  223. package/dist/run-event.js +1 -2
  224. package/dist/scheduled-op-cloud.d.ts +32 -0
  225. package/dist/scheduled-op-cloud.d.ts.map +1 -0
  226. package/dist/scheduled-op-cloud.js +69 -0
  227. package/dist/wave-runtime.mjs +340 -327
  228. package/dist/workspace/ci-lock-grain.d.ts +5 -0
  229. package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
  230. package/dist/workspace/ci-lock-grain.js +1 -7
  231. package/dist/workspace/ci-run.d.ts.map +1 -1
  232. package/dist/workspace/ci-run.js +5 -1
  233. package/dist/workspace/pr-report.schema.json +5 -0
  234. package/package.json +1 -1
  235. package/src/ci-agent.ts +1 -2
  236. package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
  237. package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
  238. package/src/ci-audit/attribution.ts +260 -0
  239. package/src/ci-audit/audit-log.ts +220 -0
  240. package/src/ci-audit/ci-audit.test.ts +175 -0
  241. package/src/ci-audit/index.ts +15 -0
  242. package/src/ci-audit/unrecorded.ts +140 -0
  243. package/src/ci-audit.ts +2 -0
  244. package/src/ci-control.ts +3 -4
  245. package/src/ci-estate.ts +1 -2
  246. package/src/ci-identity-database.test.ts +2 -3
  247. package/src/ci-identity-targets.test.ts +1 -3
  248. package/src/ci-identity.ts +2 -3
  249. package/src/ci-job-guard.test.ts +154 -0
  250. package/src/ci-job-guard.ts +319 -0
  251. package/src/ci-jobs.ts +8 -0
  252. package/src/ci-product-comment-targets.test.ts +45 -0
  253. package/src/ci-product-words.ts +35 -6
  254. package/src/ci-product.ts +55 -3
  255. package/src/ci-respond-run.ts +291 -0
  256. package/src/ci-respond.test.ts +264 -0
  257. package/src/ci-respond.ts +412 -0
  258. package/src/cli/handlers/audit-log.ts +74 -0
  259. package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
  260. package/src/cli/handlers/build.ts +69 -0
  261. package/src/cli/handlers/ci-check-job.test.ts +114 -0
  262. package/src/cli/handlers/ci-check-job.ts +33 -0
  263. package/src/cli/handlers/ci-check.ts +38 -8
  264. package/src/cli/handlers/e2e-safe-run.ts +27 -0
  265. package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
  266. package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
  267. package/src/cli/handlers/pr.ts +228 -4
  268. package/src/cli/handlers/run-wave.ts +79 -1
  269. package/src/cli/main.test.ts +1 -1
  270. package/src/cli/main.ts +56 -2
  271. package/src/cli/parse-args.ts +77 -0
  272. package/src/cli/registry.ts +38 -0
  273. package/src/components/adoption.ts +1 -2
  274. package/src/components/capability.ts +50 -0
  275. package/src/components/check-hooks.ts +4 -1
  276. package/src/components/check-steps.test.ts +70 -0
  277. package/src/components/check-steps.ts +158 -0
  278. package/src/components/ci-services.ts +1 -2
  279. package/src/components/driver.ts +35 -1
  280. package/src/components/groups.ts +4 -2
  281. package/src/components/plan-flags.test.ts +46 -0
  282. package/src/components/pr-comment-preview-targets.test.ts +34 -0
  283. package/src/components/pr-env-ledger.ts +1 -2
  284. package/src/components/pr-env-run-bundle.test.ts +0 -20
  285. package/src/components/pr-environment.ts +1 -1
  286. package/src/components/pr-pipeline-runners.test.ts +80 -0
  287. package/src/components/pr-pipeline.ts +232 -17
  288. package/src/components/pr-run.ts +17 -6
  289. package/src/components/pr-stale-job.test.ts +34 -0
  290. package/src/components/product-pipeline.ts +50 -8
  291. package/src/components/wave-plan.ts +18 -2
  292. package/src/e2e-harness/__project__/chant.config.ts +4 -0
  293. package/src/e2e-harness/__project__/src/compose.ts +33 -0
  294. package/src/e2e-harness/bucket.ts +69 -0
  295. package/src/e2e-harness/claim.test.ts +150 -0
  296. package/src/e2e-harness/claim.ts +140 -0
  297. package/src/e2e-harness/driver.test.ts +304 -0
  298. package/src/e2e-harness/driver.ts +294 -0
  299. package/src/e2e-harness/forgejo.ts +267 -0
  300. package/src/e2e-harness/git.ts +96 -0
  301. package/src/e2e-harness/index.ts +50 -0
  302. package/src/e2e-harness/jobs.ts +35 -0
  303. package/src/e2e-harness/pins.ts +52 -0
  304. package/src/e2e-harness/ports.ts +130 -0
  305. package/src/e2e-harness/reports.ts +79 -0
  306. package/src/e2e-harness/safe-run-cli.test.ts +102 -0
  307. package/src/e2e-harness/safe-run-cli.ts +54 -0
  308. package/src/e2e-harness/safe-run.ts +198 -0
  309. package/src/e2e-harness/scenario.ts +89 -0
  310. package/src/e2e-harness/schemas/README.md +62 -0
  311. package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  312. package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
  313. package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  314. package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  315. package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  316. package/src/e2e-harness/schemas/index.ts +220 -0
  317. package/src/e2e-harness/schemas.test.ts +145 -0
  318. package/src/e2e-harness/stack.test.ts +124 -0
  319. package/src/e2e-harness/stack.ts +306 -0
  320. package/src/e2e-harness/steps.ts +30 -0
  321. package/src/e2e-harness.ts +2 -0
  322. package/src/exit-codes.test.ts +3 -2
  323. package/src/exit-codes.ts +7 -1
  324. package/src/gate-decision-bundle.test.ts +0 -2
  325. package/src/lexicon.ts +48 -0
  326. package/src/lifecycle/control-entries-ledger.test.ts +2 -3
  327. package/src/lifecycle/gate-ledger.ts +2 -3
  328. package/src/lifecycle/gated-request.ts +1 -2
  329. package/src/lifecycle/query.ts +4 -5
  330. package/src/lifecycle/release-catalog.test.ts +3 -4
  331. package/src/lifecycle/release-catalog.ts +1 -1
  332. package/src/lifecycle/release-ledger.ts +1 -2
  333. package/src/lifecycle/release-status.test.ts +3 -4
  334. package/src/lifecycle/release-status.ts +1 -2
  335. package/src/lifecycle/wave-plans.ts +33 -5
  336. package/src/op/approval-status.test.ts +134 -0
  337. package/src/op/approval-status.ts +235 -0
  338. package/src/op/gate-review.test.ts +2 -1
  339. package/src/op/index.ts +2 -0
  340. package/src/op/op-waves-after-plan.test.ts +12 -0
  341. package/src/op/op-waves-capability-spec.ts +20 -0
  342. package/src/op/op-waves-parallelism.test.ts +89 -0
  343. package/src/op/op-waves-pull-request.test.ts +78 -1
  344. package/src/op/op-waves-release.ts +1 -2
  345. package/src/op/op-waves-run.ts +94 -4
  346. package/src/op/op-waves-stand-down.ts +1 -2
  347. package/src/op/op-waves.ts +63 -6
  348. package/src/op/runtime.ts +6 -3
  349. package/src/otlp.ts +1 -2
  350. package/src/parallelism.test.ts +38 -0
  351. package/src/parallelism.ts +33 -0
  352. package/src/policy-source.ts +1 -2
  353. package/src/pr-forge-bundle.test.ts +1 -1
  354. package/src/pr-forge.ts +54 -35
  355. package/src/pr-loop-bundle.test.ts +1 -1
  356. package/src/pr-loop-narrowed.test.ts +63 -0
  357. package/src/pr-loop.ts +30 -3
  358. package/src/pr-merge.test.ts +100 -0
  359. package/src/pr-merge.ts +105 -0
  360. package/src/pr-post-stale.test.ts +163 -0
  361. package/src/pr-post.ts +159 -5
  362. package/src/pr-report-url.ts +1 -2
  363. package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
  364. package/src/release-floors.ts +1 -1
  365. package/src/run-event.ts +1 -2
  366. package/src/scheduled-op-cloud.ts +68 -0
  367. package/src/stage-hooks-bundle.test.ts +0 -2
  368. package/src/workspace/ci-lock-grain.ts +1 -2
  369. package/src/workspace/ci-run.ts +5 -1
  370. package/src/workspace/pr-report.schema.json +5 -0
@@ -0,0 +1,304 @@
1
+ /**
2
+ * The harness's driver (chant#4587) running a scenario in process, with
3
+ * fakes for the forge, the report bucket, chant, the ledger and the clock. A
4
+ * fake pipeline writes chant's reports where the jobs would: pr-plan.json at
5
+ * the head when a pull request opens, pr-apply.json at the merge commit when
6
+ * it merges. Nothing here starts a container or opens a socket.
7
+ */
8
+ import { describe, expect, test } from "vitest";
9
+ import type { OpRunRecord } from "../op/runtime";
10
+ import { runArm, runClaim, verdictsOf, type DriverPorts } from "./driver";
11
+ import type { ApproveInput, Bucket, Clock, ForgeIssue, PullForge } from "./ports";
12
+ import { reportObjectKey } from "./reports";
13
+ import { lintScenario } from "./scenario";
14
+ import { E2E_SCENARIO_SCHEMA, type Scenario } from "./schemas/index";
15
+
16
+ const PREFIX = "shop/reports";
17
+
18
+ /** The fan-out story as a scenario: the change fails cluster-a, the fix applies the seven. */
19
+ function fanOut(over: Partial<Scenario> = {}): Scenario {
20
+ return {
21
+ $schema: E2E_SCENARIO_SCHEMA,
22
+ contract: 1,
23
+ id: "fan-out",
24
+ product: "chant",
25
+ claim: "fan-out/failure-blocks-dependents",
26
+ tree: { base: "../..", overlays: "overlays" },
27
+ env: "demo",
28
+ reportUrl: `s3://chant-demo/${PREFIX}`,
29
+ steps: [
30
+ { id: "change", do: "open", branch: "demo/change", overlay: "change", title: "The change" },
31
+ { id: "change-plan", do: "plan", pull: "change", expect: [{ report: { status: "planned" } }] },
32
+ { id: "change-approve", do: "approve", pull: "change" },
33
+ { id: "change-merge", do: "merge", pull: "change" },
34
+ {
35
+ id: "change-apply",
36
+ do: "apply",
37
+ merge: "change-merge",
38
+ expect: [{ report: { status: "failed", components: { "cluster-a": "failed", "app-01": "blocked", "cluster-b": "applied" } } }],
39
+ },
40
+ ],
41
+ break: { env: { BREAK: "1" }, note: "cluster-a's queue gets a valid name, so nothing fails" },
42
+ ...over,
43
+ };
44
+ }
45
+
46
+ /** Time that moves only when the driver sleeps. */
47
+ function fakeClock(start = Date.parse("2026-10-28T10:00:00Z")): Clock & { t: number } {
48
+ const c = {
49
+ t: start,
50
+ now: () => c.t,
51
+ sleep: async (ms: number) => {
52
+ c.t += ms;
53
+ },
54
+ };
55
+ return c;
56
+ }
57
+
58
+ function fakeBucket(): Bucket & { objects: Map<string, string> } {
59
+ const objects = new Map<string, string>();
60
+ return {
61
+ objects,
62
+ get: async (k) => objects.get(k) ?? null,
63
+ put: async (k, b) => void objects.set(k, b),
64
+ list: async (p) => [...objects.keys()].filter((k) => k.startsWith(p)),
65
+ delete: async (k) => void objects.delete(k),
66
+ };
67
+ }
68
+
69
+ interface World {
70
+ ports: DriverPorts;
71
+ bucket: ReturnType<typeof fakeBucket>;
72
+ clock: ReturnType<typeof fakeClock>;
73
+ approvals: ApproveInput[];
74
+ opened: Array<{ branch: string; files: Record<string, string> }>;
75
+ comments: Map<number, string[]>;
76
+ ledger: OpRunRecord[];
77
+ resets: number;
78
+ armEnv: Record<string, string>[];
79
+ log: string[];
80
+ }
81
+
82
+ /**
83
+ * A forge and a pipeline that plans and applies on its own. `broken` is what
84
+ * BREAK=1 does to the pipeline here: cluster-a applies cleanly, so the
85
+ * failure the claim is about never happens. `silent` stops the pipeline from
86
+ * writing an apply report at all.
87
+ */
88
+ function world(o: { silent?: boolean; breakDoesNothing?: boolean } = {}): World {
89
+ const bucket = fakeBucket();
90
+ const clock = fakeClock();
91
+ const approvals: ApproveInput[] = [];
92
+ const opened: World["opened"] = [];
93
+ const comments = new Map<number, string[]>();
94
+ const ledger: OpRunRecord[] = [];
95
+ const log: string[] = [];
96
+ let broken = false;
97
+ let next = 1;
98
+ const heads = new Map<number, string>();
99
+ const sha = (n: number, kind: string) => `${kind}${String(n).padStart(40 - kind.length, "0")}`;
100
+ const w = { resets: 0, armEnv: [] as Record<string, string>[] };
101
+
102
+ const forge: PullForge & { comments(pull: number): Promise<string[]>; issues(): Promise<ForgeIssue[]> } = {
103
+ async pushBranch(branch, files) {
104
+ opened.push({ branch, files });
105
+ return sha(opened.length, "a");
106
+ },
107
+ async openPull(branch) {
108
+ const pull = next++;
109
+ const head = sha(opened.findIndex((x) => x.branch === branch) + 1, "a");
110
+ heads.set(pull, head);
111
+ // The pipeline's plan job.
112
+ await bucket.put(
113
+ reportObjectKey(PREFIX, pull, head, "plan"),
114
+ JSON.stringify({ stage: "plan", pr: pull, head, op: `pr-${pull}`, gate: "pr-apply", digest: `jcs1-sha256:${pull}`, status: "planned", selection: { waves: [] }, members: [] }),
115
+ "application/json",
116
+ );
117
+ comments.set(pull, [`plan for #${pull}: 15 stacks in 3 waves`]);
118
+ return pull;
119
+ },
120
+ async approvePull() {},
121
+ async mergePull(pull) {
122
+ const commit = sha(pull, "b");
123
+ if (!o.silent) {
124
+ const clusterA = broken ? "applied" : "failed";
125
+ const app01 = broken ? "applied" : "blocked";
126
+ await bucket.put(
127
+ reportObjectKey(PREFIX, pull, commit, "apply"),
128
+ JSON.stringify({
129
+ stage: "apply",
130
+ pr: pull,
131
+ head: commit,
132
+ op: `pr-${pull}`,
133
+ gate: "pr-apply",
134
+ digest: "",
135
+ status: broken ? "applied" : "failed",
136
+ selection: { waves: [] },
137
+ members: [
138
+ { member: "cluster-a", component: "cluster-a", status: clusterA },
139
+ { member: "app-01", component: "app-01", status: app01 },
140
+ { member: "cluster-b", component: "cluster-b", status: "applied" },
141
+ ],
142
+ }),
143
+ "application/json",
144
+ );
145
+ ledger.push({
146
+ version: 1,
147
+ id: `run-${pull}`,
148
+ op: "pr-apply",
149
+ env: "demo",
150
+ started: new Date(clock.now()).toISOString(),
151
+ ended: new Date(clock.now()).toISOString(),
152
+ status: broken ? "ok" : "fail",
153
+ labels: {},
154
+ outcomes: {},
155
+ phases: [],
156
+ });
157
+ }
158
+ return commit;
159
+ },
160
+ openPulls: async () => [],
161
+ closePull: async () => {},
162
+ forceMain: async () => {},
163
+ branches: async () => [],
164
+ deleteBranch: async () => {},
165
+ comments: async (pull) => comments.get(pull) ?? [],
166
+ issues: async () => [{ number: 9, title: "drift: shop-dev", body: "", open: true }],
167
+ };
168
+
169
+ const ports: DriverPorts = {
170
+ forge,
171
+ bucket,
172
+ clock,
173
+ chant: { approve: async (i) => void approvals.push(i) },
174
+ overlay: (name) => ({ [`src/${name}.ts`]: `export const overlay = "${name}";\n` }),
175
+ ledger: { runs: async (env, op) => ledger.filter((r) => r.env === env && r.op === op) },
176
+ reset: async () => {
177
+ w.resets++;
178
+ },
179
+ arm: async (arm, env) => {
180
+ w.armEnv.push(env);
181
+ broken = arm === "break" && env.BREAK === "1" && !o.breakDoesNothing;
182
+ },
183
+ log: (line) => log.push(line),
184
+ };
185
+ return { ports, bucket, clock, approvals, opened, comments, ledger, log, get resets() { return w.resets; }, get armEnv() { return w.armEnv; } } as World;
186
+ }
187
+
188
+ const OPTS = { approver: "forgejo@forgejo:3000:reviewer", pollMs: 1000 };
189
+
190
+ describe("the e2e harness's driver", () => {
191
+ test("the fixture scenario lints clean", () => {
192
+ expect(lintScenario(fanOut())).toEqual([]);
193
+ });
194
+
195
+ test("a plain run whose outcomes all hold passes, and approves the plan's digest as the reviewer", async () => {
196
+ const w = world();
197
+ const run = await runArm(fanOut(), "plain", w.ports, OPTS);
198
+ expect(run.outcome).toBe("held");
199
+ expect(run.steps.map((s) => s.id)).toEqual(["change", "change-plan", "change-approve", "change-merge", "change-apply"]);
200
+ expect(w.approvals).toEqual([{ pull: 1, op: "pr-1", gate: "pr-apply", digest: "jcs1-sha256:1", approver: "forgejo@forgejo:3000:reviewer" }]);
201
+ expect(w.opened[0]).toEqual({ branch: "demo/change", files: { "src/change.ts": 'export const overlay = "change";\n' } });
202
+ });
203
+
204
+ test("the BREAK run is caught when an outcome stops holding, on its own branch", async () => {
205
+ const w = world();
206
+ const claim = await runClaim(fanOut(), w.ports, OPTS);
207
+ expect(claim.plain.outcome).toBe("held");
208
+ expect(claim.break.outcome).toBe("broke");
209
+ expect(claim.break.reason).toMatch(/change-apply: the apply report ended applied, not failed/);
210
+ expect(claim.break.steps.at(-1)?.stopped?.outcome).toBe("broke");
211
+ expect(claim.verdicts).toEqual({ plain: "pass", break: "caught" });
212
+ expect(w.opened.map((o) => o.branch)).toEqual(["demo/change", "demo/change-break"]);
213
+ expect(w.resets).toBe(2);
214
+ expect(w.armEnv).toEqual([{}, { BREAK: "1" }]);
215
+ });
216
+
217
+ test("a BREAK run that changes nothing is missed", async () => {
218
+ const w = world({ breakDoesNothing: true });
219
+ const claim = await runClaim(fanOut(), w.ports, OPTS);
220
+ expect(claim.verdicts).toEqual({ plain: "pass", break: "missed" });
221
+ });
222
+
223
+ test("a report that never comes stalls the run past its limit, and a stall is neither verdict", async () => {
224
+ const w = world({ silent: true });
225
+ const run = await runArm(fanOut({ limits: { apply: 30 } }), "plain", w.ports, OPTS);
226
+ expect(run.outcome).toBe("stalled");
227
+ expect(run.reason).toMatch(/change-apply: no pr-apply.json at 1\/b0+1 within 30s/);
228
+ expect(run.steps.at(-1)).toMatchObject({ id: "change-apply", stopped: { outcome: "stalled" } });
229
+ expect(verdictsOf(run, run)).toEqual({ plain: "fail", break: "stalled" });
230
+ });
231
+
232
+ test("the break overlay goes over every pull request of the BREAK run", async () => {
233
+ const w = world();
234
+ await runArm(fanOut({ break: { env: { BREAK: "1" }, overlay: "break" } }), "break", w.ports, OPTS);
235
+ expect(w.opened[0]!.files).toEqual({
236
+ "src/change.ts": 'export const overlay = "change";\n',
237
+ "src/break.ts": 'export const overlay = "break";\n',
238
+ });
239
+ });
240
+
241
+ test("open-concurrent opens its pull request beside the open before it", async () => {
242
+ const w = world();
243
+ const s = fanOut({
244
+ steps: [
245
+ { id: "a", do: "open", branch: "a", overlay: "change", title: "A" },
246
+ { id: "b", do: "open-concurrent", branch: "b", overlay: "fix", title: "B" },
247
+ { id: "a-plan", do: "plan", pull: "a", expect: [{ report: { status: "planned" } }] },
248
+ { id: "b-plan", do: "plan", pull: "b", expect: [{ comment: "plan for #2" }] },
249
+ ],
250
+ });
251
+ expect(lintScenario(s)).toEqual([]);
252
+ const run = await runArm(s, "plain", w.ports, OPTS);
253
+ expect(run.outcome).toBe("held");
254
+ expect(run.steps.map((x) => [x.id, x.pull])).toEqual([
255
+ ["a", 1],
256
+ ["b", 2],
257
+ ["a-plan", 1],
258
+ ["b-plan", 2],
259
+ ]);
260
+ });
261
+
262
+ test("ledger, comment and issue outcomes read the ledger and the forge", async () => {
263
+ const w = world();
264
+ const s = fanOut();
265
+ s.steps[4]!.expect!.push({ ledger: { op: "pr-apply", status: "fail", count: 1 } }, { comment: "15 stacks" }, { issue: { title: "drift", open: true } });
266
+ expect((await runArm(s, "plain", w.ports, OPTS)).outcome).toBe("held");
267
+
268
+ const wrong = fanOut();
269
+ wrong.steps[4]!.expect = [{ ledger: { op: "pr-apply", status: "ok" } }];
270
+ const run = await runArm(wrong, "plain", world().ports, OPTS);
271
+ expect(run.outcome).toBe("broke");
272
+ expect(run.reason).toMatch(/no pr-apply run ok on the ledger/);
273
+ });
274
+
275
+ test("out-of-band and kill-job steps go through their ports, and stall without them", async () => {
276
+ const w = world();
277
+ const ran: string[][] = [];
278
+ const killed: Array<string | undefined> = [];
279
+ const s = fanOut({
280
+ steps: [
281
+ { id: "drift", do: "out-of-band", command: ["aws", "sqs", "tag-queue"], expect: [{ exit: 0 }] },
282
+ { id: "kill", do: "kill-job", match: "pr-apply" },
283
+ ],
284
+ });
285
+ const run = await runArm(s, "plain", { ...w.ports, outOfBand: { run: async (c) => (ran.push(c), 0) }, jobs: { kill: async (m) => (killed.push(m), true) } }, OPTS);
286
+ expect(run.outcome).toBe("held");
287
+ expect(ran).toEqual([["aws", "sqs", "tag-queue"]]);
288
+ expect(killed).toEqual(["pr-apply"]);
289
+
290
+ const bare = await runArm(s, "plain", w.ports, OPTS);
291
+ expect(bare.outcome).toBe("stalled");
292
+ expect(bare.reason).toMatch(/drift: an out-of-band step needs the out-of-band port/);
293
+
294
+ const none = await runArm(s, "plain", { ...w.ports, outOfBand: { run: async () => 0 }, jobs: { kill: async () => false } }, OPTS);
295
+ expect(none.reason).toMatch(/kill: no running job matching pr-apply to kill/);
296
+ });
297
+
298
+ test("a forge error stalls the run at its step", async () => {
299
+ const w = world();
300
+ const run = await runArm(fanOut(), "plain", { ...w.ports, forge: { ...w.ports.forge, mergePull: async () => Promise.reject(new Error("Forgejo answered 500")) } }, OPTS);
301
+ expect(run.outcome).toBe("stalled");
302
+ expect(run.reason).toBe("change-merge: Forgejo answered 500");
303
+ });
304
+ });
@@ -0,0 +1,294 @@
1
+ /**
2
+ * The harness's scenario driver (chant#4587). It runs a scenario's steps in
3
+ * order against the forge, the report bucket, chant, the ledger and the
4
+ * runner's jobs as interfaces (./ports.ts), once as the plain run and once as
5
+ * the BREAK run, and checks each step's outcomes against chant's own reports
6
+ * and run ledger, never the runner's status or logs.
7
+ *
8
+ * A run ends one of three ways. Every outcome held: the plain run passes, and
9
+ * a BREAK run that ends so was missed. An outcome did not hold: the run stops
10
+ * there, the plain run fails, and the BREAK run was caught. A step did not
11
+ * finish (past its limit, or an error): the run stalled, which is neither.
12
+ */
13
+ import { reportKey } from "../pr-report-url";
14
+ import type { OpRunRecord } from "../op/runtime";
15
+ import type { Bucket, Chant, Clock, ForgeReads, Jobs, Ledger, Log, OutOfBand, PullForge } from "./ports";
16
+ import { componentStatuses, reportObjectKey, splitReportUrl, waitForReport, type PrReportView, type ReportStage } from "./reports";
17
+ import type { BreakVerdict, PlainVerdict, Scenario, ScenarioOutcome, ScenarioStep, ScenarioStepKind } from "./schemas/index";
18
+ import { limitsFor } from "./steps";
19
+
20
+ export type Arm = "plain" | "break";
21
+
22
+ export interface DriverPorts {
23
+ forge: PullForge & Partial<ForgeReads>;
24
+ /** The bucket the scenario's report URL names. */
25
+ bucket: Bucket;
26
+ chant: Pick<Chant, "approve">;
27
+ clock: Clock;
28
+ /** An overlay's files, repo-relative path to content. */
29
+ overlay(name: string): Record<string, string>;
30
+ ledger?: Ledger;
31
+ jobs?: Jobs;
32
+ outOfBand?: OutOfBand;
33
+ /** Put the repo and the stacks back to the base, before each run. */
34
+ reset?(): Promise<void>;
35
+ /** Hand the run's environment to where the pipeline reads it (the runner's secrets file). */
36
+ arm?(arm: Arm, env: Record<string, string>): Promise<void>;
37
+ log?: Log;
38
+ }
39
+
40
+ export interface DriverOptions {
41
+ /** Who approves, as chant names reviewers: `forgejo@forgejo:3000:<login>`. */
42
+ approver: string;
43
+ /** How often reports are polled, in ms. Default 2000. */
44
+ pollMs?: number;
45
+ }
46
+
47
+ export interface StepResult {
48
+ id: string;
49
+ do: ScenarioStepKind;
50
+ pull?: number;
51
+ commit?: string;
52
+ /** Why the run stopped at this step. */
53
+ stopped?: { outcome: "broke" | "stalled"; reason: string };
54
+ }
55
+
56
+ export interface ArmRun {
57
+ scenario: string;
58
+ arm: Arm;
59
+ outcome: "held" | "broke" | "stalled";
60
+ reason?: string;
61
+ started: string;
62
+ ended: string;
63
+ steps: StepResult[];
64
+ }
65
+
66
+ /** A step past its limit or one that errored: the run stalls. */
67
+ class Stall extends Error {}
68
+ /** An outcome that did not hold: the run broke. */
69
+ class Broke extends Error {}
70
+
71
+ interface Opened {
72
+ pull: number;
73
+ head: string;
74
+ }
75
+
76
+ const iso = (ms: number) => new Date(ms).toISOString();
77
+
78
+ /** The check of one outcome, or null when it holds. */
79
+ async function checkOutcome(
80
+ o: ScenarioOutcome,
81
+ ctx: { report?: PrReportView; pull?: number; exit?: number; since: string; env: string },
82
+ p: DriverPorts,
83
+ ): Promise<string | null> {
84
+ if ("report" in o) {
85
+ const r = ctx.report;
86
+ if (!r) return "no report to read";
87
+ if (o.report.status !== undefined && r.status !== o.report.status) return `the ${r.stage} report ended ${r.status}, not ${o.report.status}`;
88
+ if (o.report.components) {
89
+ const s = componentStatuses(r);
90
+ for (const [name, want] of Object.entries(o.report.components)) {
91
+ if (s.get(name) !== want) return `${name} is ${s.get(name) ?? "missing"} in the ${r.stage} report, not ${want}`;
92
+ }
93
+ if (o.report.only) {
94
+ const extra = [...s.keys()].filter((k) => !(k in o.report.components!));
95
+ if (extra.length > 0) return `the ${r.stage} report reaches ${extra.join(", ")} beyond the ones named`;
96
+ }
97
+ }
98
+ return null;
99
+ }
100
+ if ("ledger" in o) {
101
+ if (!p.ledger) throw new Stall("a ledger outcome needs the ledger port");
102
+ const runs = (await p.ledger.runs(ctx.env, o.ledger.op)).filter((r: OpRunRecord) => r.started >= ctx.since);
103
+ const matching = o.ledger.status ? runs.filter((r) => r.status === o.ledger.status) : runs;
104
+ if (o.ledger.count !== undefined) {
105
+ return matching.length === o.ledger.count ? null : `${matching.length} ${o.ledger.op} runs${o.ledger.status ? ` ${o.ledger.status}` : ""} on the ledger, not ${o.ledger.count}`;
106
+ }
107
+ return matching.length > 0 ? null : `no ${o.ledger.op} run${o.ledger.status ? ` ${o.ledger.status}` : ""} on the ledger since the run started`;
108
+ }
109
+ if ("comment" in o) {
110
+ if (!p.forge.comments) throw new Stall("a comment outcome needs the forge's comments");
111
+ if (ctx.pull === undefined) return "no pull request to read comments of";
112
+ const bodies = await p.forge.comments(ctx.pull);
113
+ return bodies.some((b) => b.includes(o.comment)) ? null : `no comment on pull request ${ctx.pull} holds "${o.comment}"`;
114
+ }
115
+ if ("issue" in o) {
116
+ if (!p.forge.issues) throw new Stall("an issue outcome needs the forge's issues");
117
+ const found = (await p.forge.issues()).filter((i) => i.title.includes(o.issue.title));
118
+ const want = o.issue.open === undefined ? found : found.filter((i) => i.open === o.issue.open);
119
+ return want.length > 0 ? null : `no ${o.issue.open === false ? "closed " : o.issue.open ? "open " : ""}issue titled "${o.issue.title}"`;
120
+ }
121
+ return ctx.exit === o.exit ? null : `the command exited ${ctx.exit ?? "nothing"}, not ${o.exit}`;
122
+ }
123
+
124
+ /** Run one arm of a scenario. */
125
+ export async function runArm(s: Scenario, arm: Arm, p: DriverPorts, opts: DriverOptions): Promise<ArmRun> {
126
+ const limits = limitsFor(s.limits);
127
+ const env = s.env ?? "local";
128
+ const { prefix } = splitReportUrl(s.reportUrl);
129
+ const log = p.log ?? (() => {});
130
+ const startedMs = p.clock.now();
131
+ const since = iso(startedMs);
132
+ const opened = new Map<string, Opened>();
133
+ const merged = new Map<string, { pull: number; commit: string }>();
134
+ const plans = new Map<string, PrReportView>();
135
+ const results: StepResult[] = [];
136
+ const done = (outcome: ArmRun["outcome"], reason?: string): ArmRun => ({
137
+ scenario: s.id,
138
+ arm,
139
+ outcome,
140
+ ...(reason ? { reason } : {}),
141
+ started: since,
142
+ ended: iso(p.clock.now()),
143
+ steps: results,
144
+ });
145
+
146
+ const files = (overlay: string): Record<string, string> => ({
147
+ ...p.overlay(overlay),
148
+ ...(arm === "break" && s.break.overlay ? p.overlay(s.break.overlay) : {}),
149
+ });
150
+ const branchOf = (b: string) => (arm === "break" ? `${b}-break` : b);
151
+ const deadlineOf = (kind: ScenarioStepKind) => p.clock.now() + limits[kind] * 1000;
152
+ const report = async (stage: ReportStage, pr: number, commit: string, kind: ScenarioStepKind): Promise<PrReportView> => {
153
+ const key = reportObjectKey(prefix, pr, commit, stage);
154
+ const r = await waitForReport(p.bucket, key, p.clock, deadlineOf(kind), opts.pollMs ?? 2000);
155
+ if (!r) throw new Stall(`no pr-${stage}.json at ${reportKey(pr, commit)} within ${limits[kind]}s`);
156
+ return r;
157
+ };
158
+ // Forge and chant calls carry their own timeouts; a call that came back
159
+ // after its step's limit stalls the run all the same.
160
+ const within = async <T>(kind: ScenarioStepKind, work: Promise<T>): Promise<T> => {
161
+ const deadline = deadlineOf(kind);
162
+ const out = await work;
163
+ if (p.clock.now() > deadline) throw new Stall(`${kind} did not finish within ${limits[kind]}s`);
164
+ return out;
165
+ };
166
+ const open = async (step: Extract<ScenarioStep, { do: "open" | "open-concurrent" }>): Promise<StepResult> => {
167
+ const head = await within(step.do, p.forge.pushBranch(branchOf(step.branch), files(step.overlay), step.title));
168
+ const pull = await within(step.do, p.forge.openPull(branchOf(step.branch), step.title, step.body ?? step.title));
169
+ opened.set(step.id, { pull, head });
170
+ log(`${s.id} ${arm}: ${step.id} opened pull request ${pull} at ${head.slice(0, 8)}`);
171
+ return { id: step.id, do: step.do, pull, commit: head };
172
+ };
173
+ const pullOf = (id: string): Opened => {
174
+ const o = opened.get(id);
175
+ if (!o) throw new Stall(`no pull request from ${id}`);
176
+ return o;
177
+ };
178
+
179
+ try {
180
+ await p.reset?.();
181
+ await p.arm?.(arm, arm === "break" ? { ...s.break.env } : {});
182
+ for (let i = 0; i < s.steps.length; i++) {
183
+ const step = s.steps[i]!;
184
+ let result: StepResult;
185
+ const ctx: { report?: PrReportView; pull?: number; exit?: number; since: string; env: string } = { since, env };
186
+ switch (step.do) {
187
+ case "open":
188
+ case "open-concurrent": {
189
+ // An open and the open-concurrent steps after it go out together.
190
+ const group = [step];
191
+ while (s.steps[i + 1]?.do === "open-concurrent") group.push(s.steps[++i] as typeof step);
192
+ const all = await Promise.all(group.map((g) => open(g as Extract<ScenarioStep, { do: "open" | "open-concurrent" }>)));
193
+ for (let g = 0; g < group.length; g++) {
194
+ const gs = group[g]!;
195
+ const r = all[g]!;
196
+ for (const o of gs.expect ?? []) {
197
+ const why = await checkOutcome(o, { ...ctx, pull: r.pull }, p);
198
+ if (why) {
199
+ results.push({ ...r, stopped: { outcome: "broke", reason: why } });
200
+ throw new Broke(`${gs.id}: ${why}`);
201
+ }
202
+ }
203
+ results.push(r);
204
+ }
205
+ continue;
206
+ }
207
+ case "plan": {
208
+ const o = pullOf(step.pull);
209
+ const r = await report("plan", o.pull, o.head, "plan");
210
+ plans.set(step.pull, r);
211
+ ctx.report = r;
212
+ ctx.pull = o.pull;
213
+ result = { id: step.id, do: step.do, pull: o.pull, commit: o.head };
214
+ break;
215
+ }
216
+ case "approve": {
217
+ const o = pullOf(step.pull);
218
+ const plan = plans.get(step.pull) ?? (await report("plan", o.pull, o.head, "approve"));
219
+ await within("approve", p.forge.approvePull(o.pull, `Approved by the e2e harness (${s.id}, ${arm}).`));
220
+ await within("approve", p.chant.approve({ pull: o.pull, op: plan.op, gate: plan.gate, digest: plan.digest, approver: opts.approver }));
221
+ ctx.pull = o.pull;
222
+ result = { id: step.id, do: step.do, pull: o.pull };
223
+ break;
224
+ }
225
+ case "merge": {
226
+ const o = pullOf(step.pull);
227
+ const commit = await within("merge", p.forge.mergePull(o.pull));
228
+ merged.set(step.id, { pull: o.pull, commit });
229
+ ctx.pull = o.pull;
230
+ result = { id: step.id, do: step.do, pull: o.pull, commit };
231
+ break;
232
+ }
233
+ case "apply": {
234
+ const m = merged.get(step.merge);
235
+ if (!m) throw new Stall(`no merge from ${step.merge}`);
236
+ ctx.report = await report("apply", m.pull, m.commit, "apply");
237
+ ctx.pull = m.pull;
238
+ result = { id: step.id, do: step.do, pull: m.pull, commit: m.commit };
239
+ break;
240
+ }
241
+ case "out-of-band": {
242
+ if (!p.outOfBand) throw new Stall("an out-of-band step needs the out-of-band port");
243
+ ctx.exit = await within("out-of-band", p.outOfBand.run(step.command));
244
+ result = { id: step.id, do: step.do };
245
+ break;
246
+ }
247
+ case "kill-job": {
248
+ if (!p.jobs) throw new Stall("a kill-job step needs the jobs port");
249
+ const killed = await within("kill-job", p.jobs.kill(step.match));
250
+ if (!killed) throw new Stall(`no running job${step.match ? ` matching ${step.match}` : ""} to kill`);
251
+ result = { id: step.id, do: step.do };
252
+ break;
253
+ }
254
+ }
255
+ for (const o of step.expect ?? []) {
256
+ const why = await checkOutcome(o, ctx, p);
257
+ if (why) {
258
+ results.push({ ...result, stopped: { outcome: "broke", reason: why } });
259
+ throw new Broke(`${step.id}: ${why}`);
260
+ }
261
+ }
262
+ results.push(result);
263
+ log(`${s.id} ${arm}: ${step.id} held`);
264
+ }
265
+ return done("held");
266
+ } catch (err) {
267
+ if (err instanceof Broke) return done("broke", err.message);
268
+ const reason = err instanceof Error ? err.message : String(err);
269
+ const at = s.steps[results.length]?.id;
270
+ if (at && !results.some((r) => r.stopped)) results.push({ id: at, do: s.steps[results.length]!.do, stopped: { outcome: "stalled", reason } });
271
+ return done("stalled", at ? `${at}: ${reason}` : reason);
272
+ }
273
+ }
274
+
275
+ /** The row's verdicts from the two runs. */
276
+ export function verdictsOf(plain: Pick<ArmRun, "outcome">, brk: Pick<ArmRun, "outcome">): { plain: PlainVerdict; break: BreakVerdict } {
277
+ return {
278
+ plain: plain.outcome === "held" ? "pass" : "fail",
279
+ break: brk.outcome === "broke" ? "caught" : brk.outcome === "held" ? "missed" : "stalled",
280
+ };
281
+ }
282
+
283
+ export interface ClaimRun {
284
+ plain: ArmRun;
285
+ break: ArmRun;
286
+ verdicts: { plain: PlainVerdict; break: BreakVerdict };
287
+ }
288
+
289
+ /** The plain run, then the BREAK run, and their verdicts. */
290
+ export async function runClaim(s: Scenario, p: DriverPorts, opts: DriverOptions): Promise<ClaimRun> {
291
+ const plain = await runArm(s, "plain", p, opts);
292
+ const brk = await runArm(s, "break", p, opts);
293
+ return { plain, break: brk, verdicts: verdictsOf(plain, brk) };
294
+ }