@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,267 @@
1
+ /**
2
+ * The forge, for real: the harness's Forgejo, through its REST API and git
3
+ * over http, as three people (chant#4587, from the fan-out demo's
4
+ * lib/forgejo.ts). The author pushes, opens and merges; the reviewer
5
+ * approves; the admin forces main back and deletes branches. Every call
6
+ * names one repository on the harness's own Forgejo, and nothing else.
7
+ *
8
+ * It also has sql-yodeler's verbs: a pull request's comments, the issues,
9
+ * and a workflow run started by hand (the apply again, the drift watch).
10
+ */
11
+ import { mkdirSync, rmSync, writeFileSync } from "node:fs";
12
+ import { dirname, join } from "node:path";
13
+ import { guardedGit, remoteWith, type GuardedGit } from "./git";
14
+ import type { Clock, ForgeIssue, ForgeRun, HarnessForge } from "./ports";
15
+ import { forgejoRunnerConfig, type RunnerConfigOptions } from "./stack";
16
+
17
+ export interface Person {
18
+ login: string;
19
+ token: string;
20
+ }
21
+
22
+ export interface ForgejoOptions {
23
+ /** Forgejo as the driver reaches it, http://localhost:<port>. */
24
+ url: string;
25
+ /** `<org>/<repo>`. */
26
+ repo: string;
27
+ admin: Person;
28
+ author: Person;
29
+ reviewer: Person;
30
+ /** A git repository holding the base commit, which forceMain pushes from. */
31
+ baseTree: string;
32
+ clock: Clock;
33
+ /** The checkout git work must stay outside of. */
34
+ checkout?: string;
35
+ /** How long a workflow run may take, in seconds. Default 900. */
36
+ runLimit?: number;
37
+ /** The domain of the people's commit emails. Default chant-e2e.local. */
38
+ emailDomain?: string;
39
+ }
40
+
41
+ const TIMEOUT_MS = 30_000;
42
+
43
+ /** One Forgejo API call. A 404 is null when `missingOk`; any other non-2xx throws. */
44
+ export async function forgejoApi<T = unknown>(
45
+ url: string,
46
+ token: string,
47
+ method: string,
48
+ path: string,
49
+ body?: unknown,
50
+ opts: { missingOk?: boolean; basic?: { login: string; password: string } } = {},
51
+ ): Promise<T | null> {
52
+ const headers: Record<string, string> = { accept: "application/json" };
53
+ if (opts.basic) headers.authorization = `Basic ${Buffer.from(`${opts.basic.login}:${opts.basic.password}`).toString("base64")}`;
54
+ else if (token) headers.authorization = `token ${token}`;
55
+ if (body !== undefined) headers["content-type"] = "application/json";
56
+ const res = await fetch(`${url.replace(/\/$/, "")}/api/v1${path}`, {
57
+ method,
58
+ headers,
59
+ body: body === undefined ? undefined : JSON.stringify(body),
60
+ signal: AbortSignal.timeout(TIMEOUT_MS),
61
+ });
62
+ if (res.status === 404 && opts.missingOk) return null;
63
+ const text = await res.text();
64
+ if (!res.ok) throw new Error(`Forgejo ${method} ${path} answered ${res.status}: ${text.slice(0, 200)}`);
65
+ return (text ? JSON.parse(text) : {}) as T;
66
+ }
67
+
68
+ /** A workflow run as Forgejo's actions API lists it, the fields read here. */
69
+ interface ActionRun {
70
+ id: number;
71
+ status: string;
72
+ commit_sha?: string;
73
+ workflow_id?: string;
74
+ }
75
+
76
+ const DONE = new Set(["success", "failure", "cancelled", "skipped"]);
77
+
78
+ export class ForgejoForge implements HarnessForge {
79
+ private readonly g: GuardedGit;
80
+
81
+ constructor(private readonly o: ForgejoOptions) {
82
+ this.g = guardedGit(o.checkout);
83
+ }
84
+
85
+ private api<T>(who: Person, method: string, path: string, body?: unknown, missingOk = false): Promise<T | null> {
86
+ return forgejoApi<T>(this.o.url, who.token, method, path, body, { missingOk });
87
+ }
88
+
89
+ private remote(who: Person): string {
90
+ return remoteWith(this.o.url, who.login, who.token, this.o.repo);
91
+ }
92
+
93
+ private get r(): string {
94
+ return `/repos/${this.o.repo}`;
95
+ }
96
+
97
+ async pushBranch(branch: string, files: Record<string, string>, message: string): Promise<string> {
98
+ const a = this.o.author;
99
+ const dir = await this.g.clone(this.remote(a), "author", [a.token]);
100
+ try {
101
+ await this.g.git(dir, ["checkout", "-q", "-b", branch]);
102
+ for (const [path, content] of Object.entries(files)) {
103
+ const to = join(dir, ...path.split("/"));
104
+ mkdirSync(dirname(to), { recursive: true });
105
+ writeFileSync(to, content);
106
+ }
107
+ await this.g.git(dir, ["add", "-A"]);
108
+ await this.g.git(dir, ["-c", `user.name=${a.login}`, "-c", `user.email=${a.login}@${this.o.emailDomain ?? "chant-e2e.local"}`, "-c", "commit.gpgsign=false", "commit", "-q", "-m", message]);
109
+ await this.g.git(dir, ["push", "-q", "--force", "origin", `HEAD:refs/heads/${branch}`], [a.token]);
110
+ return await this.g.git(dir, ["rev-parse", "HEAD"]);
111
+ } finally {
112
+ rmSync(dir, { recursive: true, force: true });
113
+ }
114
+ }
115
+
116
+ async openPull(branch: string, title: string, body: string): Promise<number> {
117
+ const pull = await this.api<{ number?: number }>(this.o.author, "POST", `${this.r}/pulls`, { head: branch, base: "main", title, body });
118
+ if (!pull?.number) throw new Error(`no pull request opened from ${branch}`);
119
+ return pull.number;
120
+ }
121
+
122
+ async approvePull(pull: number, body: string): Promise<void> {
123
+ await this.api(this.o.reviewer, "POST", `${this.r}/pulls/${pull}/reviews`, { event: "APPROVED", body });
124
+ }
125
+
126
+ async mergePull(pull: number): Promise<string> {
127
+ // Forgejo checks a pull request's mergeability after it opens, so the
128
+ // first try can be refused; it is tried again a few times.
129
+ let lastErr: unknown;
130
+ let merged = false;
131
+ for (let i = 0; i < 10 && !merged; i++) {
132
+ try {
133
+ await this.api(this.o.author, "POST", `${this.r}/pulls/${pull}/merge`, { Do: "merge" });
134
+ merged = true;
135
+ } catch (err) {
136
+ lastErr = err;
137
+ await this.o.clock.sleep(2000);
138
+ }
139
+ }
140
+ if (!merged) throw new Error(`pull request ${pull} did not merge: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}`);
141
+ for (let i = 0; i < 30; i++) {
142
+ const pr = await this.api<{ merge_commit_sha?: string }>(this.o.author, "GET", `${this.r}/pulls/${pull}`);
143
+ if (pr?.merge_commit_sha) return pr.merge_commit_sha;
144
+ await this.o.clock.sleep(1000);
145
+ }
146
+ throw new Error(`pull request ${pull} merged, but Forgejo names no merge commit`);
147
+ }
148
+
149
+ async openPulls(): Promise<number[]> {
150
+ const pulls = await this.api<Array<{ number: number }>>(this.o.admin, "GET", `${this.r}/pulls?state=open&limit=50`);
151
+ return (pulls ?? []).map((p) => p.number);
152
+ }
153
+
154
+ async closePull(pull: number): Promise<void> {
155
+ await this.api(this.o.admin, "PATCH", `${this.r}/pulls/${pull}`, { state: "closed" });
156
+ }
157
+
158
+ async forceMain(sha: string): Promise<void> {
159
+ const a = this.o.admin;
160
+ await this.g.git(this.o.baseTree, ["push", "-q", "--force", this.remote(a), `${sha}:refs/heads/main`], [a.token]);
161
+ }
162
+
163
+ async branches(): Promise<string[]> {
164
+ const out: string[] = [];
165
+ for (let page = 1; page < 50; page++) {
166
+ const list = await this.api<Array<{ name: string }>>(this.o.admin, "GET", `${this.r}/branches?page=${page}&limit=50`);
167
+ if (!list || list.length === 0) break;
168
+ out.push(...list.map((b) => b.name));
169
+ if (list.length < 50) break;
170
+ }
171
+ return out;
172
+ }
173
+
174
+ async deleteBranch(name: string): Promise<void> {
175
+ await this.api(this.o.admin, "DELETE", `${this.r}/branches/${encodeURIComponent(name)}`, undefined, true);
176
+ }
177
+
178
+ async comments(pull: number): Promise<string[]> {
179
+ const out: string[] = [];
180
+ for (let page = 1; page < 50; page++) {
181
+ const list = await this.api<Array<{ body: string }>>(this.o.admin, "GET", `${this.r}/issues/${pull}/comments?page=${page}&limit=50`);
182
+ if (!list || list.length === 0) break;
183
+ out.push(...list.map((c) => c.body));
184
+ if (list.length < 50) break;
185
+ }
186
+ return out;
187
+ }
188
+
189
+ async issues(): Promise<ForgeIssue[]> {
190
+ const out: ForgeIssue[] = [];
191
+ for (let page = 1; page < 50; page++) {
192
+ const list = await this.api<Array<{ number: number; title: string; body?: string; state: string }>>(
193
+ this.o.admin,
194
+ "GET",
195
+ `${this.r}/issues?state=all&type=issues&page=${page}&limit=50`,
196
+ );
197
+ if (!list || list.length === 0) break;
198
+ out.push(...list.map((i) => ({ number: i.number, title: i.title, body: i.body ?? "", open: i.state === "open" })));
199
+ if (list.length < 50) break;
200
+ }
201
+ return out;
202
+ }
203
+
204
+ applyAgain(sha: string, workflow: string): Promise<ForgeRun> {
205
+ return this.dispatch(sha, workflow);
206
+ }
207
+
208
+ watch(sha: string, workflow: string): Promise<ForgeRun> {
209
+ return this.dispatch(sha, workflow);
210
+ }
211
+
212
+ /** Start `workflow` on main by hand and wait for the run it started at `sha`. */
213
+ private async dispatch(sha: string, workflow: string): Promise<ForgeRun> {
214
+ const before = new Set((await this.runs()).map((r) => r.id));
215
+ await this.api(this.o.admin, "POST", `${this.r}/actions/workflows/${encodeURIComponent(workflow)}/dispatches`, { ref: "main" });
216
+ const deadline = this.o.clock.now() + (this.o.runLimit ?? 900) * 1000;
217
+ let id: number | undefined;
218
+ while (this.o.clock.now() < deadline) {
219
+ const runs = await this.runs();
220
+ const run = id === undefined ? runs.find((r) => !before.has(r.id) && (!r.commit_sha || r.commit_sha === sha)) : runs.find((r) => r.id === id);
221
+ if (run) {
222
+ id = run.id;
223
+ if (DONE.has(run.status)) return { ok: run.status === "success", status: run.status, id: run.id };
224
+ }
225
+ await this.o.clock.sleep(2000);
226
+ }
227
+ throw new Error(`${workflow} on ${sha.slice(0, 8)} did not finish within ${this.o.runLimit ?? 900}s`);
228
+ }
229
+
230
+ private async runs(): Promise<ActionRun[]> {
231
+ const page = await this.api<{ workflow_runs?: ActionRun[] }>(this.o.admin, "GET", `${this.r}/actions/runs?limit=50`);
232
+ return page?.workflow_runs ?? [];
233
+ }
234
+ }
235
+
236
+ export interface RegisterRunnerOptions extends Omit<RunnerConfigOptions, "uuid" | "token"> {
237
+ /** Forgejo as the driver reaches it. */
238
+ url: string;
239
+ adminToken: string;
240
+ /** The runner's name on the forge. */
241
+ name: string;
242
+ /** Write the config into the runner's /data/config.yml (`docker compose exec -T forgejoRunner sh -c 'cat > ...'`). */
243
+ writeConfig(text: string): Promise<void>;
244
+ /** Restart the runner so a running one reads the new credentials. */
245
+ restart(): Promise<void>;
246
+ }
247
+
248
+ /**
249
+ * Register forgejo-runner the Forgejo 16 / runner 13 way (terragucci
250
+ * stack/bootstrap.sh): create the runner on the server, which answers with a
251
+ * uuid and a token, drop earlier registrations of the same name that are
252
+ * offline, write the config naming that pair, and restart the runner.
253
+ */
254
+ export async function registerForgejoRunner(o: RegisterRunnerOptions): Promise<{ uuid: string }> {
255
+ const listed = await forgejoApi<Array<{ id: number; name: string; status: string }>>(o.url, o.adminToken, "GET", "/admin/actions/runners");
256
+ for (const stale of (listed ?? []).filter((r) => r.name === o.name && r.status === "offline")) {
257
+ await forgejoApi(o.url, o.adminToken, "DELETE", `/admin/actions/runners/${stale.id}`, undefined, { missingOk: true });
258
+ }
259
+ const reg = await forgejoApi<{ uuid?: string; token?: string }>(o.url, o.adminToken, "POST", "/admin/actions/runners", {
260
+ name: o.name,
261
+ description: "chant e2e harness, docker executor",
262
+ });
263
+ if (!reg?.uuid || !reg.token) throw new Error("Forgejo created no runner (no uuid or token in its answer)");
264
+ await o.writeConfig(forgejoRunnerConfig({ ...o, uuid: reg.uuid, token: reg.token }));
265
+ await o.restart();
266
+ return { uuid: reg.uuid };
267
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * git for the harness's driver, from the fan-out demo's lib/git.ts, with one
3
+ * guard: every git command runs in a directory whose own `.git` is the
4
+ * repository, outside the checkout the driver runs from. A clone that failed
5
+ * would otherwise leave git to find that checkout's repository above it, and
6
+ * the driver would push or approve there.
7
+ */
8
+ import { execFile } from "node:child_process";
9
+ import { existsSync, mkdtempSync, realpathSync } from "node:fs";
10
+ import { tmpdir } from "node:os";
11
+ import { join, relative } from "node:path";
12
+
13
+ /** Whether `dir` is `checkout` or below it. */
14
+ export function insideCheckout(dir: string, checkout: string): boolean {
15
+ const rel = relative(realpathSync(checkout), realpathSync(dir));
16
+ return rel === "" || (!rel.startsWith("..") && !rel.startsWith("/"));
17
+ }
18
+
19
+ /** Refuse a directory that is in `checkout` (when given) or has no `.git` of its own. */
20
+ export function assertOwnRepo(dir: string, checkout?: string): void {
21
+ if (checkout && insideCheckout(dir, checkout)) throw new Error(`${dir} is inside ${checkout}; the driver's git work stays outside it`);
22
+ if (!existsSync(join(dir, ".git"))) throw new Error(`${dir} has no .git of its own`);
23
+ }
24
+
25
+ /** A new empty directory under the system temp dir. */
26
+ export function freshDir(name: string, prefix = "chant-e2e"): string {
27
+ return mkdtempSync(join(tmpdir(), `${prefix}-${name}-`));
28
+ }
29
+
30
+ export interface RunResult {
31
+ stdout: string;
32
+ stderr: string;
33
+ }
34
+
35
+ export interface RunOptions {
36
+ cwd?: string;
37
+ env?: NodeJS.ProcessEnv;
38
+ input?: string;
39
+ timeoutMs?: number;
40
+ /** Secrets blanked in an error. */
41
+ redact?: string[];
42
+ }
43
+
44
+ /** Run a program, rejecting with its last stderr lines. */
45
+ export function run(file: string, args: string[], opts: RunOptions = {}): Promise<RunResult> {
46
+ return new Promise((resolveRun, reject) => {
47
+ const child = execFile(
48
+ file,
49
+ args,
50
+ { cwd: opts.cwd, env: opts.env ?? process.env, timeout: opts.timeoutMs ?? 300_000, maxBuffer: 64 * 1024 * 1024 },
51
+ (err, stdout, stderr) => {
52
+ if (!err) return resolveRun({ stdout: String(stdout), stderr: String(stderr) });
53
+ let text = `${file} ${args[0] ?? ""} failed: ${String(stderr).trim().split("\n").slice(-3).join(" / ") || err.message}`;
54
+ for (const secret of opts.redact ?? []) if (secret) text = text.split(secret).join("***");
55
+ reject(new Error(text));
56
+ },
57
+ );
58
+ if (opts.input !== undefined) child.stdin?.end(opts.input);
59
+ });
60
+ }
61
+
62
+ const gitEnv = (): NodeJS.ProcessEnv => ({ ...process.env, GIT_TERMINAL_PROMPT: "0" });
63
+
64
+ /** git bound to a checkout the driver must stay out of. */
65
+ export interface GuardedGit {
66
+ /** git in `dir`, which must be its own repository outside the checkout. */
67
+ git(dir: string, args: string[], redact?: string[]): Promise<string>;
68
+ /** Clone `remote` into a fresh directory outside the checkout. */
69
+ clone(remote: string, name: string, redact?: string[]): Promise<string>;
70
+ assertOwnRepo(dir: string): void;
71
+ }
72
+
73
+ export function guardedGit(checkout?: string, prefix = "chant-e2e"): GuardedGit {
74
+ const own = (dir: string) => assertOwnRepo(dir, checkout);
75
+ return {
76
+ assertOwnRepo: own,
77
+ async git(dir, args, redact = []) {
78
+ own(dir);
79
+ return (await run("git", ["-C", dir, ...args], { env: gitEnv(), redact })).stdout.trim();
80
+ },
81
+ async clone(remote, name, redact = []) {
82
+ const dir = freshDir(name, prefix);
83
+ await run("git", ["clone", "-q", remote, dir], { env: gitEnv(), redact });
84
+ own(dir);
85
+ return dir;
86
+ },
87
+ };
88
+ }
89
+
90
+ /** An http remote with a login and token in it. */
91
+ export function remoteWith(url: string, login: string, token: string, repo: string): string {
92
+ const u = new URL(url);
93
+ u.username = login;
94
+ u.password = token;
95
+ return `${u.toString().replace(/\/$/, "")}/${repo}.git`;
96
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * `@intentius/chant/e2e-harness` (chant#4587): the one e2e harness that
3
+ * terragucci, plywood and sql-yodeler run their scenarios on, and that the
4
+ * engines' claims cite (chant#4586 rulings B and D).
5
+ *
6
+ * - the stack: ./stack.ts's compose services and ./project/, the chant
7
+ * docker-lexicon project that wraps them, with every image in ./pins.ts
8
+ * - the driver: ./driver.ts over ./ports.ts, with the real Forgejo
9
+ * (./forgejo.ts), floci's S3 (./bucket.ts) and the runner's jobs (./jobs.ts)
10
+ * - the scenario format and its lint: ./scenario.ts, e2e-scenario/v1
11
+ * - the claim row protocol: ./claim.ts, e2e-claim-row/v1 as an e2e-claim
12
+ * run record on the ledger, rendered as e2e-claims/v1
13
+ * - the no-real-cloud wrapper: ./safe-run.ts
14
+ *
15
+ * A product on a published chant without this subpath feature-detects:
16
+ * import it lazily, and use it when `E2E_HARNESS_FLOOR` is there.
17
+ */
18
+ import { existsSync } from "node:fs";
19
+ import { join } from "node:path";
20
+ import { NEXT_RELEASE } from "../release-floors";
21
+
22
+ /** The first chant with the e2e harness. */
23
+ export const E2E_HARNESS_FLOOR = NEXT_RELEASE;
24
+
25
+ /**
26
+ * The harness's chant docker-lexicon project, to `chant build <dir>/src
27
+ * --lexicon docker`. It ships as source in the package's src/.
28
+ */
29
+ export function harnessProjectDir(): string {
30
+ const here = import.meta.dirname;
31
+ const candidates = [join(here, "__project__"), join(here, "..", "..", "src", "e2e-harness", "__project__")];
32
+ const found = candidates.find((d) => existsSync(join(d, "src", "compose.ts")));
33
+ if (!found) throw new Error(`the e2e harness's compose project is not next to ${here}`);
34
+ return found;
35
+ }
36
+
37
+ export * from "./pins";
38
+ export * from "./stack";
39
+ export * from "./ports";
40
+ export * from "./git";
41
+ export * from "./forgejo";
42
+ export * from "./bucket";
43
+ export * from "./jobs";
44
+ export * from "./reports";
45
+ export * from "./steps";
46
+ export * from "./scenario";
47
+ export * from "./driver";
48
+ export * from "./claim";
49
+ export * from "./safe-run";
50
+ export * from "./schemas/index";
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The kill-job step, for real (chant#4587): forgejo-runner's docker
3
+ * executor runs each job in a container on the project network, named
4
+ * `FORGEJO-ACTIONS-TASK-<id>_WORKFLOW-<name>_JOB-<name>`. Killing the newest
5
+ * one that matches is a job dying mid-run, the way a runner host does.
6
+ */
7
+ import { run } from "./git";
8
+ import type { Jobs } from "./ports";
9
+
10
+ /** forgejo-runner's job containers carry this in their names. */
11
+ export const JOB_CONTAINER_MARK = "ACTIONS-TASK";
12
+
13
+ /** Pick the container to kill from `docker ps` lines (`<created>\t<name>`), newest first by docker's order. */
14
+ export function pickJobContainer(psLines: string[], match?: string): string | null {
15
+ for (const line of psLines) {
16
+ const name = line.split("\t").pop()?.trim() ?? "";
17
+ if (!name.includes(JOB_CONTAINER_MARK)) continue;
18
+ if (match && !name.includes(match)) continue;
19
+ return name;
20
+ }
21
+ return null;
22
+ }
23
+
24
+ /** Jobs on `network`, through the host's docker. */
25
+ export function dockerJobs(network: string): Jobs {
26
+ return {
27
+ async kill(match) {
28
+ const ps = await run("docker", ["ps", "--filter", `network=${network}`, "--format", "{{.CreatedAt}}\t{{.Names}}"]);
29
+ const name = pickJobContainer(ps.stdout.split("\n").filter(Boolean), match);
30
+ if (!name) return false;
31
+ await run("docker", ["kill", name]);
32
+ return true;
33
+ },
34
+ };
35
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The images the e2e harness runs (chant#4587), in the one file every
3
+ * harness compose reads. A product's compose project gets its images from
4
+ * here through `harnessStack` (./stack.ts), never by naming a digest itself,
5
+ * so a pin moves for every bench at once.
6
+ */
7
+
8
+ /** The floci build the harness pins, by its index digest (linux/amd64 and linux/arm64). */
9
+ export const FLOCI_DIGEST = "sha256:5ec92ae8046445d62c0009590dd09f04560886e5a5ef31248cb3fcc09b2961ec";
10
+
11
+ /**
12
+ * floci from the lex00/floci fork at {@link FLOCI_DIGEST}: the build
13
+ * choudoufu pins in live/floci-image and plunge in
14
+ * tests/plunge-corpus/emulator-images, which serves Cloud Control
15
+ * ListResources for the types choudoufu's discovery and plunge's sweep read.
16
+ *
17
+ * The epic named 63d8f1ed (chant#4586 ruling D). On 2026-10-27 the
18
+ * maintainer ruled to hold this pin at 5ec92ae8 and file upstream instead,
19
+ * because 63d8f1ed answers ListResources with UnsupportedActionException for
20
+ * 619 of 628 Cloud Control types. lex00/floci#265 asks for one image with
21
+ * both lines' fixes; the pin moves when that image exists.
22
+ */
23
+ export const FLOCI_IMAGE = `ghcr.io/lex00/floci@${FLOCI_DIGEST}`;
24
+
25
+ /**
26
+ * The other floci line, 63d8f1ed (ghcr.io/lex00/floci:b491869, branch
27
+ * fix/cfn-change-set-changes): it describes a CloudFormation change set's
28
+ * changes, which chant's plan counts read, and keeps SNS tags and IAM
29
+ * permission boundaries. The fan-out demo plans CloudFormation stacks and
30
+ * needs that, so it names this line until lex00/floci#265's image carries
31
+ * both. No claim row is recorded on it: rows name {@link FLOCI_DIGEST}.
32
+ */
33
+ export const FLOCI_CHANGE_SET_DIGEST = "sha256:63d8f1ed5ef595d7356c6f76318f3d76bc31ce3250cdf2dd8d14bd4d59604b8d";
34
+ export const FLOCI_CHANGE_SET_IMAGE = `ghcr.io/lex00/floci@${FLOCI_CHANGE_SET_DIGEST}`;
35
+
36
+ /** Forgejo, as terragucci's stack and the fan-out demo run it. */
37
+ export const FORGEJO_IMAGE = "codeberg.org/forgejo/forgejo:16.0.5";
38
+
39
+ /** forgejo-runner, with the docker executor (terragucci stack/docker-compose.yml). */
40
+ export const FORGEJO_RUNNER_IMAGE = "data.forgejo.org/forgejo/runner:13.2.0";
41
+
42
+ /**
43
+ * The sql emulator's servers, the ones `chant emulator up sql` starts. The
44
+ * sql lexicon owns these pins (lexicons/sql/src/spec/pin.ts and
45
+ * postgres-pin.ts); stack.test.ts fails when the two disagree.
46
+ */
47
+ export const CLICKHOUSE_IMAGE =
48
+ "clickhouse/clickhouse-server:26.8.15.10@sha256:9716a352d25f538bd19d868b001141e7a60e4d035bc9b823658c6a071660aa61";
49
+ export const POSTGRES_IMAGE = "postgres:18.6@sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722";
50
+
51
+ /** The Postgres emulator's password, as `chant emulator` sets it. */
52
+ export const POSTGRES_PASSWORD = "chant";
@@ -0,0 +1,130 @@
1
+ /**
2
+ * What the e2e harness's driver talks to, as small interfaces (chant#4587),
3
+ * factored from the fan-out demo's lib/ports.ts: the forge, the bucket where
4
+ * chant's reports land, chant run outside the pipeline, the ledger, and time.
5
+ * The real ones are ./forgejo.ts and ./bucket.ts; tests pass fakes.
6
+ */
7
+ import type { OpRunRecord } from "../op/runtime";
8
+
9
+ /** A forge repository as the author, the reviewer and the admin: the pull request loop. */
10
+ export interface PullForge {
11
+ /**
12
+ * As the author: clone main, write `files` over it (paths relative to the
13
+ * repo root), commit and push to `branch`. Returns the pushed head sha.
14
+ */
15
+ pushBranch(branch: string, files: Record<string, string>, message: string): Promise<string>;
16
+ /** As the author: open a pull request from `branch` into main. Returns its number. */
17
+ openPull(branch: string, title: string, body: string): Promise<number>;
18
+ /** As the reviewer: an APPROVED review of the pull request. */
19
+ approvePull(pull: number, body: string): Promise<void>;
20
+ /** As the author: merge the pull request. Returns the merge commit's sha. */
21
+ mergePull(pull: number): Promise<string>;
22
+ /** The numbers of the repo's open pull requests. */
23
+ openPulls(): Promise<number[]>;
24
+ closePull(pull: number): Promise<void>;
25
+ /** As the admin: force main to `sha`. */
26
+ forceMain(sha: string): Promise<void>;
27
+ /** The repo's branches, by name. */
28
+ branches(): Promise<string[]>;
29
+ /** Delete a branch. A branch that is gone already is not an error. */
30
+ deleteBranch(name: string): Promise<void>;
31
+ }
32
+
33
+ /** A finished workflow run on the forge. */
34
+ export interface ForgeRun {
35
+ ok: boolean;
36
+ /** The forge's word for how it ended (success, failure, cancelled, ...). */
37
+ status: string;
38
+ /** The forge's id of the run. */
39
+ id?: number;
40
+ /** The names of the jobs that did not succeed, where the forge says. */
41
+ failed?: string[];
42
+ }
43
+
44
+ export interface ForgeIssue {
45
+ number: number;
46
+ title: string;
47
+ body: string;
48
+ open: boolean;
49
+ }
50
+
51
+ /**
52
+ * sql-yodeler's Forge verbs (scenarios/forges/forge.ts:26-61) that the pull
53
+ * request loop lacks. `openPr` and `merge` there are `openPull` and
54
+ * `mergePull` here. A run's outcome is read from chant's reports and ledger,
55
+ * so a run carries its status and no log.
56
+ */
57
+ export interface ForgeReads {
58
+ /** The bodies of a pull request's comments, oldest first. */
59
+ comments(pull: number): Promise<string[]>;
60
+ /** The repository's issues, open and closed, without pull requests. */
61
+ issues(): Promise<ForgeIssue[]>;
62
+ }
63
+
64
+ export interface ForgeRuns {
65
+ /** The apply again, started by hand on main at `sha` (workflow dispatch of `workflow`). */
66
+ applyAgain(sha: string, workflow: string): Promise<ForgeRun>;
67
+ /** A scheduled workflow (the drift watch) run by hand on main at `sha`, waited for. */
68
+ watch(sha: string, workflow: string): Promise<ForgeRun>;
69
+ }
70
+
71
+ /** The jobs the forge's runner is running, for the kill-job step. */
72
+ export interface Jobs {
73
+ /** Kill the newest running job whose name holds `match` (any job when absent). Resolves with whether one was running. */
74
+ kill(match?: string): Promise<boolean>;
75
+ }
76
+
77
+ /** Everything the harness asks of a forge. */
78
+ export type HarnessForge = PullForge & ForgeReads & ForgeRuns;
79
+
80
+ /** A bucket, keys below its root. */
81
+ export interface Bucket {
82
+ /** The object's text, or null when there is none. */
83
+ get(key: string): Promise<string | null>;
84
+ put(key: string, body: string, contentType: string): Promise<void>;
85
+ /** Every key that starts with `prefix`. */
86
+ list(prefix: string): Promise<string[]>;
87
+ delete(key: string): Promise<void>;
88
+ }
89
+
90
+ /** The plan a reviewer approves, as pr-plan.json names it. */
91
+ export interface ApproveInput {
92
+ pull: number;
93
+ op: string;
94
+ gate: string;
95
+ digest: string;
96
+ approver: string;
97
+ }
98
+
99
+ /** chant, run by the driver outside the pipeline. */
100
+ export interface Chant {
101
+ /** `chant approve <op> <gate> --plan <digest> --approver <approver> --sign <key>` from the reviewer's clone. */
102
+ approve(input: ApproveInput): Promise<void>;
103
+ /** The base's templates built and applied outside the pipeline. */
104
+ applyBase(): Promise<void>;
105
+ }
106
+
107
+ /** The run ledger of the scenario's repo (`chant/lifecycle`), read. */
108
+ export interface Ledger {
109
+ runs(env: string, op: string): Promise<OpRunRecord[]>;
110
+ }
111
+
112
+ /** Work outside the forge and chant: a change made out of band. */
113
+ export interface OutOfBand {
114
+ /** Run `command` with the no-real-cloud environment. Resolves with its exit code. */
115
+ run(command: string[]): Promise<number>;
116
+ }
117
+
118
+ /** Time, so a test runs a scenario without waiting. */
119
+ export interface Clock {
120
+ now(): number;
121
+ sleep(ms: number): Promise<void>;
122
+ }
123
+
124
+ export const realClock: Clock = {
125
+ now: () => Date.now(),
126
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
127
+ };
128
+
129
+ /** A log line for the person running the driver. */
130
+ export type Log = (line: string) => void;