opencastle 1.3.1 → 1.4.0

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 (486) hide show
  1. package/README.md +16 -10
  2. package/bin/cli.mjs +8 -9
  3. package/dist/cli/agent-roster.test.js +0 -48
  4. package/dist/cli/agent-roster.test.js.map +1 -1
  5. package/dist/cli/boundary.test.js +9 -7
  6. package/dist/cli/boundary.test.js.map +1 -1
  7. package/dist/cli/convoy/artifacts.d.ts +9 -2
  8. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  9. package/dist/cli/convoy/artifacts.js +13 -10
  10. package/dist/cli/convoy/artifacts.js.map +1 -1
  11. package/dist/cli/convoy/artifacts.test.js +4 -2
  12. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  13. package/dist/cli/convoy/engine.d.ts +53 -23
  14. package/dist/cli/convoy/engine.d.ts.map +1 -1
  15. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  16. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/engine.git.test.js +435 -0
  18. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  19. package/dist/cli/convoy/engine.js +1746 -2305
  20. package/dist/cli/convoy/engine.js.map +1 -1
  21. package/dist/cli/convoy/engine.test.js +698 -678
  22. package/dist/cli/convoy/engine.test.js.map +1 -1
  23. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  24. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  25. package/dist/cli/convoy/event-schemas.js +59 -57
  26. package/dist/cli/convoy/event-schemas.js.map +1 -1
  27. package/dist/cli/convoy/events.d.ts +4 -1
  28. package/dist/cli/convoy/events.d.ts.map +1 -1
  29. package/dist/cli/convoy/events.js +69 -84
  30. package/dist/cli/convoy/events.js.map +1 -1
  31. package/dist/cli/convoy/events.test.js +50 -9
  32. package/dist/cli/convoy/events.test.js.map +1 -1
  33. package/dist/cli/convoy/gates.d.ts +9 -4
  34. package/dist/cli/convoy/gates.d.ts.map +1 -1
  35. package/dist/cli/convoy/gates.js +29 -14
  36. package/dist/cli/convoy/gates.js.map +1 -1
  37. package/dist/cli/convoy/isolation.d.ts +32 -6
  38. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  39. package/dist/cli/convoy/isolation.js +72 -34
  40. package/dist/cli/convoy/isolation.js.map +1 -1
  41. package/dist/cli/convoy/isolation.test.js +66 -42
  42. package/dist/cli/convoy/isolation.test.js.map +1 -1
  43. package/dist/cli/convoy/lock.d.ts.map +1 -1
  44. package/dist/cli/convoy/lock.js +25 -10
  45. package/dist/cli/convoy/lock.js.map +1 -1
  46. package/dist/cli/convoy/lock.test.js +12 -0
  47. package/dist/cli/convoy/lock.test.js.map +1 -1
  48. package/dist/cli/convoy/merge.d.ts +21 -4
  49. package/dist/cli/convoy/merge.d.ts.map +1 -1
  50. package/dist/cli/convoy/merge.js +69 -53
  51. package/dist/cli/convoy/merge.js.map +1 -1
  52. package/dist/cli/convoy/merge.test.js +23 -1
  53. package/dist/cli/convoy/merge.test.js.map +1 -1
  54. package/dist/cli/convoy/progress.d.ts +35 -0
  55. package/dist/cli/convoy/progress.d.ts.map +1 -0
  56. package/dist/cli/convoy/progress.js +103 -0
  57. package/dist/cli/convoy/progress.js.map +1 -0
  58. package/dist/cli/convoy/progress.test.d.ts +2 -0
  59. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  60. package/dist/cli/convoy/progress.test.js +53 -0
  61. package/dist/cli/convoy/progress.test.js.map +1 -0
  62. package/dist/cli/convoy/read-model.d.ts +468 -0
  63. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  64. package/dist/cli/convoy/read-model.js +1132 -0
  65. package/dist/cli/convoy/read-model.js.map +1 -0
  66. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  67. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  68. package/dist/cli/convoy/read-model.test.js +609 -0
  69. package/dist/cli/convoy/read-model.test.js.map +1 -0
  70. package/dist/cli/convoy/redact.d.ts +34 -0
  71. package/dist/cli/convoy/redact.d.ts.map +1 -0
  72. package/dist/cli/convoy/redact.js +66 -0
  73. package/dist/cli/convoy/redact.js.map +1 -0
  74. package/dist/cli/convoy/redact.test.d.ts +2 -0
  75. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  76. package/dist/cli/convoy/redact.test.js +43 -0
  77. package/dist/cli/convoy/redact.test.js.map +1 -0
  78. package/dist/cli/convoy/reviewer.d.ts +65 -0
  79. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  80. package/dist/cli/convoy/reviewer.js +141 -0
  81. package/dist/cli/convoy/reviewer.js.map +1 -0
  82. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  83. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  84. package/dist/cli/convoy/reviewer.test.js +96 -0
  85. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  86. package/dist/cli/convoy/schedule.d.ts +30 -0
  87. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  88. package/dist/cli/convoy/schedule.js +111 -0
  89. package/dist/cli/convoy/schedule.js.map +1 -0
  90. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  91. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  92. package/dist/cli/convoy/schedule.test.js +45 -0
  93. package/dist/cli/convoy/schedule.test.js.map +1 -0
  94. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  95. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  96. package/dist/cli/convoy/spec-builder.js +438 -114
  97. package/dist/cli/convoy/spec-builder.js.map +1 -1
  98. package/dist/cli/convoy/spec-builder.test.js +419 -435
  99. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  100. package/dist/cli/convoy/spec-types.d.ts +46 -92
  101. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  102. package/dist/cli/convoy/store.d.ts +6 -1
  103. package/dist/cli/convoy/store.d.ts.map +1 -1
  104. package/dist/cli/convoy/store.js +111 -15
  105. package/dist/cli/convoy/store.js.map +1 -1
  106. package/dist/cli/convoy/store.test.js +59 -13
  107. package/dist/cli/convoy/store.test.js.map +1 -1
  108. package/dist/cli/convoy/types.d.ts +76 -113
  109. package/dist/cli/convoy/types.d.ts.map +1 -1
  110. package/dist/cli/convoy/types.js +6 -13
  111. package/dist/cli/convoy/types.js.map +1 -1
  112. package/dist/cli/convoy/worktree.d.ts +88 -3
  113. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  114. package/dist/cli/convoy/worktree.js +282 -56
  115. package/dist/cli/convoy/worktree.js.map +1 -1
  116. package/dist/cli/convoy/worktree.test.js +132 -1
  117. package/dist/cli/convoy/worktree.test.js.map +1 -1
  118. package/dist/cli/convoy-args.test.js +9 -27
  119. package/dist/cli/convoy-args.test.js.map +1 -1
  120. package/dist/cli/convoy-cmd.d.ts +31 -6
  121. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  122. package/dist/cli/convoy-cmd.js +150 -201
  123. package/dist/cli/convoy-cmd.js.map +1 -1
  124. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  125. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  126. package/dist/cli/convoy-cmd.test.js +144 -0
  127. package/dist/cli/convoy-cmd.test.js.map +1 -0
  128. package/dist/cli/dashboard.d.ts +24 -11
  129. package/dist/cli/dashboard.d.ts.map +1 -1
  130. package/dist/cli/dashboard.js +241 -303
  131. package/dist/cli/dashboard.js.map +1 -1
  132. package/dist/cli/dashboard.test.d.ts +2 -0
  133. package/dist/cli/dashboard.test.d.ts.map +1 -0
  134. package/dist/cli/dashboard.test.js +340 -0
  135. package/dist/cli/dashboard.test.js.map +1 -0
  136. package/dist/cli/dispatcher.test.js +35 -2
  137. package/dist/cli/dispatcher.test.js.map +1 -1
  138. package/dist/cli/docs-accuracy.test.js +3 -3
  139. package/dist/cli/docs-accuracy.test.js.map +1 -1
  140. package/dist/cli/log.d.ts +39 -0
  141. package/dist/cli/log.d.ts.map +1 -1
  142. package/dist/cli/log.js +267 -93
  143. package/dist/cli/log.js.map +1 -1
  144. package/dist/cli/log.test.d.ts +2 -0
  145. package/dist/cli/log.test.d.ts.map +1 -0
  146. package/dist/cli/log.test.js +208 -0
  147. package/dist/cli/log.test.js.map +1 -0
  148. package/dist/cli/nearest.d.ts +18 -0
  149. package/dist/cli/nearest.d.ts.map +1 -0
  150. package/dist/cli/nearest.js +38 -0
  151. package/dist/cli/nearest.js.map +1 -0
  152. package/dist/cli/nearest.test.d.ts +2 -0
  153. package/dist/cli/nearest.test.d.ts.map +1 -0
  154. package/dist/cli/nearest.test.js +24 -0
  155. package/dist/cli/nearest.test.js.map +1 -0
  156. package/dist/cli/pipeline.d.ts +61 -0
  157. package/dist/cli/pipeline.d.ts.map +1 -1
  158. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  159. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  160. package/dist/cli/pipeline.flow.test.js +524 -0
  161. package/dist/cli/pipeline.flow.test.js.map +1 -0
  162. package/dist/cli/pipeline.js +471 -690
  163. package/dist/cli/pipeline.js.map +1 -1
  164. package/dist/cli/plan.d.ts +82 -31
  165. package/dist/cli/plan.d.ts.map +1 -1
  166. package/dist/cli/plan.js +167 -507
  167. package/dist/cli/plan.js.map +1 -1
  168. package/dist/cli/plan.test.d.ts +2 -0
  169. package/dist/cli/plan.test.d.ts.map +1 -0
  170. package/dist/cli/plan.test.js +158 -0
  171. package/dist/cli/plan.test.js.map +1 -0
  172. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  173. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  174. package/dist/cli/run/adapters/agent-process.js +224 -0
  175. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  176. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  177. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  178. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  179. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  180. package/dist/cli/run/adapters/claude.d.ts +53 -2
  181. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  182. package/dist/cli/run/adapters/claude.js +147 -171
  183. package/dist/cli/run/adapters/claude.js.map +1 -1
  184. package/dist/cli/run/adapters/claude.test.js +197 -254
  185. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  186. package/dist/cli/run/adapters/codex.d.ts +25 -2
  187. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  188. package/dist/cli/run/adapters/codex.js +113 -81
  189. package/dist/cli/run/adapters/codex.js.map +1 -1
  190. package/dist/cli/run/adapters/codex.test.js +116 -95
  191. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  192. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  193. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  194. package/dist/cli/run/adapters/copilot.js +104 -287
  195. package/dist/cli/run/adapters/copilot.js.map +1 -1
  196. package/dist/cli/run/adapters/copilot.test.js +122 -282
  197. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  198. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  199. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  200. package/dist/cli/run/adapters/cursor.js +103 -156
  201. package/dist/cli/run/adapters/cursor.js.map +1 -1
  202. package/dist/cli/run/adapters/cursor.test.js +106 -218
  203. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  204. package/dist/cli/run/adapters/index.d.ts +34 -5
  205. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  206. package/dist/cli/run/adapters/index.js +147 -21
  207. package/dist/cli/run/adapters/index.js.map +1 -1
  208. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  209. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  210. package/dist/cli/run/adapters/index.test.js +129 -0
  211. package/dist/cli/run/adapters/index.test.js.map +1 -0
  212. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  213. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  214. package/dist/cli/run/adapters/opencode.js +136 -152
  215. package/dist/cli/run/adapters/opencode.js.map +1 -1
  216. package/dist/cli/run/adapters/opencode.test.js +99 -218
  217. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  218. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  219. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  220. package/dist/cli/run/adapters/permission-modes.js +113 -37
  221. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  222. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  223. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  224. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  225. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  226. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  227. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  228. package/dist/cli/run/platform.d.ts +52 -0
  229. package/dist/cli/run/platform.d.ts.map +1 -0
  230. package/dist/cli/run/platform.js +207 -0
  231. package/dist/cli/run/platform.js.map +1 -0
  232. package/dist/cli/run/platform.test.d.ts +2 -0
  233. package/dist/cli/run/platform.test.d.ts.map +1 -0
  234. package/dist/cli/run/platform.test.js +119 -0
  235. package/dist/cli/run/platform.test.js.map +1 -0
  236. package/dist/cli/run/schema.d.ts +6 -8
  237. package/dist/cli/run/schema.d.ts.map +1 -1
  238. package/dist/cli/run/schema.js +44 -68
  239. package/dist/cli/run/schema.js.map +1 -1
  240. package/dist/cli/run/schema.test.js +59 -279
  241. package/dist/cli/run/schema.test.js.map +1 -1
  242. package/dist/cli/run.d.ts +34 -56
  243. package/dist/cli/run.d.ts.map +1 -1
  244. package/dist/cli/run.js +379 -1132
  245. package/dist/cli/run.js.map +1 -1
  246. package/dist/cli/run.test.d.ts +2 -0
  247. package/dist/cli/run.test.d.ts.map +1 -0
  248. package/dist/cli/run.test.js +318 -0
  249. package/dist/cli/run.test.js.map +1 -0
  250. package/dist/cli/team-config.d.ts.map +1 -1
  251. package/dist/cli/team-config.js +2 -21
  252. package/dist/cli/team-config.js.map +1 -1
  253. package/dist/cli/tiers.test.js +4 -13
  254. package/dist/cli/tiers.test.js.map +1 -1
  255. package/package.json +3 -10
  256. package/src/cli/agent-roster.test.ts +0 -55
  257. package/src/cli/boundary.test.ts +9 -7
  258. package/src/cli/convoy/TELEMETRY.md +131 -125
  259. package/src/cli/convoy/artifacts.test.ts +4 -2
  260. package/src/cli/convoy/artifacts.ts +13 -12
  261. package/src/cli/convoy/engine.git.test.ts +462 -0
  262. package/src/cli/convoy/engine.test.ts +817 -850
  263. package/src/cli/convoy/engine.ts +1864 -2596
  264. package/src/cli/convoy/event-schemas.ts +63 -59
  265. package/src/cli/convoy/events.test.ts +58 -9
  266. package/src/cli/convoy/events.ts +69 -91
  267. package/src/cli/convoy/gates.ts +31 -12
  268. package/src/cli/convoy/isolation.test.ts +76 -43
  269. package/src/cli/convoy/isolation.ts +100 -38
  270. package/src/cli/convoy/lock.test.ts +16 -0
  271. package/src/cli/convoy/lock.ts +25 -8
  272. package/src/cli/convoy/merge.test.ts +25 -1
  273. package/src/cli/convoy/merge.ts +74 -61
  274. package/src/cli/convoy/progress.test.ts +59 -0
  275. package/src/cli/convoy/progress.ts +121 -0
  276. package/src/cli/convoy/read-model.test.ts +685 -0
  277. package/src/cli/convoy/read-model.ts +1469 -0
  278. package/src/cli/convoy/redact.test.ts +49 -0
  279. package/src/cli/convoy/redact.ts +73 -0
  280. package/src/cli/convoy/reviewer.test.ts +112 -0
  281. package/src/cli/convoy/reviewer.ts +196 -0
  282. package/src/cli/convoy/schedule.test.ts +56 -0
  283. package/src/cli/convoy/schedule.ts +109 -0
  284. package/src/cli/convoy/spec-builder.test.ts +460 -464
  285. package/src/cli/convoy/spec-builder.ts +460 -129
  286. package/src/cli/convoy/spec-types.ts +46 -108
  287. package/src/cli/convoy/store.test.ts +64 -13
  288. package/src/cli/convoy/store.ts +143 -33
  289. package/src/cli/convoy/types.ts +59 -71
  290. package/src/cli/convoy/worktree.test.ts +140 -1
  291. package/src/cli/convoy/worktree.ts +311 -61
  292. package/src/cli/convoy-args.test.ts +10 -30
  293. package/src/cli/convoy-cmd.test.ts +163 -0
  294. package/src/cli/convoy-cmd.ts +173 -216
  295. package/src/cli/dashboard/dashboard.css +2086 -0
  296. package/src/cli/dashboard/dashboard.js +1687 -0
  297. package/src/cli/dashboard/index.html +307 -0
  298. package/src/cli/dashboard.test.ts +382 -0
  299. package/src/cli/dashboard.ts +243 -339
  300. package/src/cli/dispatcher.test.ts +36 -2
  301. package/src/cli/docs-accuracy.test.ts +3 -3
  302. package/src/cli/log.test.ts +228 -0
  303. package/src/cli/log.ts +302 -83
  304. package/src/cli/nearest.test.ts +27 -0
  305. package/src/cli/nearest.ts +38 -0
  306. package/src/cli/pipeline.flow.test.ts +607 -0
  307. package/src/cli/pipeline.ts +544 -759
  308. package/src/cli/plan.test.ts +193 -0
  309. package/src/cli/plan.ts +209 -545
  310. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  311. package/src/cli/run/adapters/agent-process.ts +252 -0
  312. package/src/cli/run/adapters/claude.test.ts +205 -260
  313. package/src/cli/run/adapters/claude.ts +151 -162
  314. package/src/cli/run/adapters/codex.test.ts +120 -100
  315. package/src/cli/run/adapters/codex.ts +115 -91
  316. package/src/cli/run/adapters/copilot.test.ts +135 -306
  317. package/src/cli/run/adapters/copilot.ts +105 -274
  318. package/src/cli/run/adapters/cursor.test.ts +111 -220
  319. package/src/cli/run/adapters/cursor.ts +105 -156
  320. package/src/cli/run/adapters/index.test.ts +148 -0
  321. package/src/cli/run/adapters/index.ts +168 -20
  322. package/src/cli/run/adapters/opencode.test.ts +106 -227
  323. package/src/cli/run/adapters/opencode.ts +139 -151
  324. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  325. package/src/cli/run/adapters/permission-modes.ts +118 -37
  326. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  327. package/src/cli/run/platform.test.ts +128 -0
  328. package/src/cli/run/platform.ts +213 -0
  329. package/src/cli/run/schema.test.ts +62 -344
  330. package/src/cli/run/schema.ts +48 -78
  331. package/src/cli/run.test.ts +351 -0
  332. package/src/cli/run.ts +366 -1151
  333. package/src/cli/team-config.ts +2 -21
  334. package/src/cli/tiers.test.ts +4 -17
  335. package/src/orchestrator/agents/team-lead.agent.md +1 -1
  336. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  337. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  338. package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
  339. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  340. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  341. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  342. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  343. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  344. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  345. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  346. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  347. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  348. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  349. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  350. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  351. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  352. package/dist/cli/convoy/dag-analysis.js +0 -279
  353. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  354. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  355. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  356. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  357. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  358. package/dist/cli/convoy/formula.d.ts +0 -19
  359. package/dist/cli/convoy/formula.d.ts.map +0 -1
  360. package/dist/cli/convoy/formula.js +0 -142
  361. package/dist/cli/convoy/formula.js.map +0 -1
  362. package/dist/cli/convoy/formula.test.d.ts +0 -2
  363. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  364. package/dist/cli/convoy/formula.test.js +0 -342
  365. package/dist/cli/convoy/formula.test.js.map +0 -1
  366. package/dist/cli/convoy/health.d.ts +0 -34
  367. package/dist/cli/convoy/health.d.ts.map +0 -1
  368. package/dist/cli/convoy/health.js +0 -123
  369. package/dist/cli/convoy/health.js.map +0 -1
  370. package/dist/cli/convoy/health.test.d.ts +0 -2
  371. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  372. package/dist/cli/convoy/health.test.js +0 -448
  373. package/dist/cli/convoy/health.test.js.map +0 -1
  374. package/dist/cli/convoy/last-run.d.ts +0 -53
  375. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  376. package/dist/cli/convoy/last-run.js +0 -54
  377. package/dist/cli/convoy/last-run.js.map +0 -1
  378. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  379. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  380. package/dist/cli/convoy/last-run.test.js +0 -110
  381. package/dist/cli/convoy/last-run.test.js.map +0 -1
  382. package/dist/cli/convoy/pipeline.d.ts +0 -41
  383. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  384. package/dist/cli/convoy/pipeline.js +0 -414
  385. package/dist/cli/convoy/pipeline.js.map +0 -1
  386. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  387. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  388. package/dist/cli/convoy/pipeline.test.js +0 -837
  389. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  390. package/dist/cli/convoy/review-stages.d.ts +0 -9
  391. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  392. package/dist/cli/convoy/review-stages.js +0 -134
  393. package/dist/cli/convoy/review-stages.js.map +0 -1
  394. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  395. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  396. package/dist/cli/convoy/review-stages.test.js +0 -197
  397. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  398. package/dist/cli/run/executor.d.ts +0 -15
  399. package/dist/cli/run/executor.d.ts.map +0 -1
  400. package/dist/cli/run/executor.js +0 -249
  401. package/dist/cli/run/executor.js.map +0 -1
  402. package/dist/cli/run/executor.test.d.ts +0 -2
  403. package/dist/cli/run/executor.test.d.ts.map +0 -1
  404. package/dist/cli/run/executor.test.js +0 -297
  405. package/dist/cli/run/executor.test.js.map +0 -1
  406. package/dist/cli/run/reporter.d.ts +0 -10
  407. package/dist/cli/run/reporter.d.ts.map +0 -1
  408. package/dist/cli/run/reporter.js +0 -142
  409. package/dist/cli/run/reporter.js.map +0 -1
  410. package/dist/cli/run-dry-run.test.d.ts +0 -2
  411. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  412. package/dist/cli/run-dry-run.test.js +0 -83
  413. package/dist/cli/run-dry-run.test.js.map +0 -1
  414. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  415. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  416. package/dist/cli/run-executor-flags.test.js +0 -31
  417. package/dist/cli/run-executor-flags.test.js.map +0 -1
  418. package/dist/cli/run-finish.test.d.ts +0 -2
  419. package/dist/cli/run-finish.test.d.ts.map +0 -1
  420. package/dist/cli/run-finish.test.js +0 -77
  421. package/dist/cli/run-finish.test.js.map +0 -1
  422. package/dist/cli/watch.d.ts +0 -15
  423. package/dist/cli/watch.d.ts.map +0 -1
  424. package/dist/cli/watch.js +0 -277
  425. package/dist/cli/watch.js.map +0 -1
  426. package/dist/dashboard/scripts/etl.d.ts +0 -10
  427. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  428. package/dist/dashboard/scripts/etl.js +0 -141
  429. package/dist/dashboard/scripts/etl.js.map +0 -1
  430. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  431. package/src/cli/convoy/dag-analysis.ts +0 -367
  432. package/src/cli/convoy/formula.test.ts +0 -404
  433. package/src/cli/convoy/formula.ts +0 -174
  434. package/src/cli/convoy/health.test.ts +0 -519
  435. package/src/cli/convoy/health.ts +0 -189
  436. package/src/cli/convoy/last-run.test.ts +0 -130
  437. package/src/cli/convoy/last-run.ts +0 -87
  438. package/src/cli/convoy/pipeline.test.ts +0 -999
  439. package/src/cli/convoy/pipeline.ts +0 -492
  440. package/src/cli/convoy/review-stages.test.ts +0 -235
  441. package/src/cli/convoy/review-stages.ts +0 -166
  442. package/src/cli/run/executor.test.ts +0 -338
  443. package/src/cli/run/executor.ts +0 -292
  444. package/src/cli/run/reporter.ts +0 -160
  445. package/src/cli/run-dry-run.test.ts +0 -97
  446. package/src/cli/run-executor-flags.test.ts +0 -38
  447. package/src/cli/run-finish.test.ts +0 -91
  448. package/src/cli/watch.ts +0 -295
  449. package/src/dashboard/astro.config.mjs +0 -6
  450. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  451. package/src/dashboard/dist/data/.gitkeep +0 -0
  452. package/src/dashboard/dist/data/convoy-list.json +0 -1
  453. package/src/dashboard/dist/data/overall-stats.json +0 -29
  454. package/src/dashboard/dist/index.html +0 -1963
  455. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  456. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  457. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  458. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  459. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  460. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  461. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  462. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  463. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  464. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  465. package/src/dashboard/package-lock.json +0 -6
  466. package/src/dashboard/public/data/.gitkeep +0 -0
  467. package/src/dashboard/public/data/convoy-list.json +0 -1
  468. package/src/dashboard/public/data/overall-stats.json +0 -29
  469. package/src/dashboard/public/icon-192.png +0 -0
  470. package/src/dashboard/scripts/etl.test.ts +0 -166
  471. package/src/dashboard/scripts/etl.ts +0 -170
  472. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  473. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  474. package/src/dashboard/scripts/integration-test.ts +0 -504
  475. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  476. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  477. package/src/dashboard/seed-data/events.ndjson +0 -104
  478. package/src/dashboard/seed-data/panels.ndjson +0 -13
  479. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  480. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  481. package/src/dashboard/src/env.d.ts +0 -1
  482. package/src/dashboard/src/layouts/Layout.astro +0 -25
  483. package/src/dashboard/src/pages/index.astro +0 -2313
  484. package/src/dashboard/src/styles/dashboard.css +0 -2943
  485. package/src/dashboard/tsconfig.json +0 -6
  486. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -1,837 +0,0 @@
1
- import { mkdtempSync, rmSync } from 'node:fs';
2
- import { tmpdir } from 'node:os';
3
- import { join } from 'node:path';
4
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
5
- import { createPipelineOrchestrator } from './pipeline.js';
6
- import { createConvoyStore } from './store.js';
7
- // ── Suppress NDJSON log writes ────────────────────────────────────────────────
8
- vi.mock('../log.js', () => ({
9
- appendEvent: vi.fn().mockResolvedValue(undefined),
10
- }));
11
- // ── Mock fs/promises readFile ─────────────────────────────────────────────────
12
- vi.mock('node:fs/promises', () => ({
13
- readFile: vi.fn(),
14
- }));
15
- import { readFile } from 'node:fs/promises';
16
- // ── Fixture helpers ───────────────────────────────────────────────────────────
17
- function makeAdapter() {
18
- return {
19
- name: 'test-adapter',
20
- isAvailable: vi.fn().mockResolvedValue(true),
21
- execute: vi.fn().mockResolvedValue({
22
- success: true,
23
- output: 'ok',
24
- exitCode: 0,
25
- }),
26
- kill: vi.fn(),
27
- };
28
- }
29
- function makeTask(overrides = {}) {
30
- return {
31
- id: 'task-1',
32
- prompt: 'Do something',
33
- agent: 'developer',
34
- timeout: '30s',
35
- depends_on: [],
36
- files: [],
37
- description: '',
38
- max_retries: 0,
39
- ...overrides,
40
- };
41
- }
42
- function makePipelineSpec(overrides = {}) {
43
- return {
44
- name: 'Test Pipeline',
45
- concurrency: 1,
46
- on_failure: 'continue',
47
- adapter: 'test',
48
- branch: 'main',
49
- version: 2,
50
- depends_on_convoy: ['./convoy-a.yaml'],
51
- ...overrides,
52
- };
53
- }
54
- /** Minimal convoy YAML — content doesn't matter since readFile is mocked. */
55
- const CONVOY_YAML = 'name: convoy\nconcurrency: 1\non_failure: continue\nadapter: test\nbranch: main\ntasks:\n - id: task-1\n prompt: do thing\n agent: developer\n timeout: 30s\n';
56
- function makeConvoyResult(overrides = {}, status = 'done') {
57
- return {
58
- convoyId: `convoy-${Date.now()}-${Math.random().toString(36).slice(2)}`,
59
- status,
60
- summary: { total: 1, done: 1, failed: 0, skipped: 0, timedOut: 0 },
61
- duration: '100ms',
62
- ...overrides,
63
- };
64
- }
65
- /**
66
- * Create an engine factory where each successive call to engine.run() consumes
67
- * the next result from `runResults`.
68
- */
69
- function makeEngineFactory(runResults) {
70
- let idx = 0;
71
- return vi.fn((_opts) => {
72
- const result = runResults[idx++] ?? makeConvoyResult();
73
- return {
74
- run: vi.fn().mockResolvedValue(result),
75
- resume: vi.fn().mockResolvedValue(makeConvoyResult()),
76
- retryFailed: vi.fn(),
77
- injectTask: vi.fn(),
78
- };
79
- });
80
- }
81
- // ── Test lifecycle ────────────────────────────────────────────────────────────
82
- let tmpDir;
83
- let dbPath;
84
- beforeEach(() => {
85
- vi.mocked(readFile).mockResolvedValue(CONVOY_YAML);
86
- tmpDir = mkdtempSync(join(tmpdir(), 'pipeline-test-'));
87
- dbPath = join(tmpDir, 'convoy.db');
88
- });
89
- afterEach(() => {
90
- vi.clearAllMocks();
91
- rmSync(tmpDir, { recursive: true, force: true });
92
- });
93
- // ── 1. Single convoy pipeline ─────────────────────────────────────────────────
94
- describe('single convoy pipeline', () => {
95
- it('returns status done when the single convoy succeeds', async () => {
96
- const factory = makeEngineFactory([makeConvoyResult()]);
97
- const pipeline = createPipelineOrchestrator({
98
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
99
- specYaml: 'name: pipeline',
100
- adapter: makeAdapter(),
101
- dbPath,
102
- _createConvoyEngine: factory,
103
- _ensureBranch: async () => { },
104
- });
105
- const result = await pipeline.run();
106
- expect(result.status).toBe('done');
107
- expect(result.convoyResults).toHaveLength(1);
108
- expect(result.summary.totalConvoys).toBe(1);
109
- expect(result.summary.completed).toBe(1);
110
- expect(result.summary.failed).toBe(0);
111
- expect(result.summary.skipped).toBe(0);
112
- expect(typeof result.pipelineId).toBe('string');
113
- expect(typeof result.duration).toBe('string');
114
- });
115
- it('creates a pipeline record in SQLite with correct final state', async () => {
116
- const factory = makeEngineFactory([makeConvoyResult()]);
117
- const pipeline = createPipelineOrchestrator({
118
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
119
- specYaml: 'name: pipe',
120
- adapter: makeAdapter(),
121
- dbPath,
122
- _createConvoyEngine: factory,
123
- _ensureBranch: async () => { },
124
- });
125
- const result = await pipeline.run();
126
- const store = createConvoyStore(dbPath);
127
- const record = store.getPipeline(result.pipelineId);
128
- store.close();
129
- expect(record).toBeDefined();
130
- expect(record.status).toBe('done');
131
- expect(record.name).toBe('Test Pipeline');
132
- expect(record.branch).toBe('main');
133
- expect(record.finished_at).not.toBeNull();
134
- });
135
- });
136
- // ── 2. Two-convoy pipeline ────────────────────────────────────────────────────
137
- describe('two-convoy pipeline', () => {
138
- it('runs both convoys sequentially and returns done', async () => {
139
- const r1 = makeConvoyResult({ convoyId: 'convoy-1' });
140
- const r2 = makeConvoyResult({ convoyId: 'convoy-2' });
141
- const factory = makeEngineFactory([r1, r2]);
142
- const result = await createPipelineOrchestrator({
143
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml', './b.yaml'] }),
144
- specYaml: 'name: pipeline',
145
- adapter: makeAdapter(),
146
- dbPath,
147
- _createConvoyEngine: factory,
148
- _ensureBranch: async () => { },
149
- }).run();
150
- expect(result.status).toBe('done');
151
- expect(result.convoyResults).toHaveLength(2);
152
- expect(result.summary.completed).toBe(2);
153
- expect(result.summary.failed).toBe(0);
154
- expect(factory).toHaveBeenCalledTimes(2);
155
- });
156
- it('reads spec files in order', async () => {
157
- const factory = makeEngineFactory([makeConvoyResult(), makeConvoyResult()]);
158
- await createPipelineOrchestrator({
159
- spec: makePipelineSpec({ depends_on_convoy: ['./first.yaml', './second.yaml'] }),
160
- specYaml: 'name: pipeline',
161
- adapter: makeAdapter(),
162
- dbPath,
163
- _createConvoyEngine: factory,
164
- _ensureBranch: async () => { },
165
- }).run();
166
- expect(vi.mocked(readFile)).toHaveBeenNthCalledWith(1, expect.stringContaining('first.yaml'), 'utf8');
167
- expect(vi.mocked(readFile)).toHaveBeenNthCalledWith(2, expect.stringContaining('second.yaml'), 'utf8');
168
- });
169
- });
170
- // ── 3. on_failure: 'stop' ─────────────────────────────────────────────────────
171
- describe('on_failure: stop', () => {
172
- it('skips remaining convoys when second of three fails', async () => {
173
- const r1 = makeConvoyResult({ convoyId: 'c1' }, 'done');
174
- const r2 = makeConvoyResult({ convoyId: 'c2' }, 'failed');
175
- const factory = makeEngineFactory([r1, r2]);
176
- const result = await createPipelineOrchestrator({
177
- spec: makePipelineSpec({
178
- depends_on_convoy: ['./a.yaml', './b.yaml', './c.yaml'],
179
- on_failure: 'stop',
180
- }),
181
- specYaml: 'name: pipeline',
182
- adapter: makeAdapter(),
183
- dbPath,
184
- _createConvoyEngine: factory,
185
- _ensureBranch: async () => { },
186
- }).run();
187
- expect(result.status).toBe('failed');
188
- expect(result.summary.totalConvoys).toBe(3);
189
- expect(result.summary.completed).toBe(1);
190
- expect(result.summary.failed).toBe(1);
191
- expect(result.summary.skipped).toBe(1);
192
- // Engine only called twice (third skipped)
193
- expect(factory).toHaveBeenCalledTimes(2);
194
- });
195
- it('halts immediately on gate-failed convoy', async () => {
196
- const r1 = makeConvoyResult({ convoyId: 'c1' }, 'gate-failed');
197
- const factory = makeEngineFactory([r1]);
198
- const result = await createPipelineOrchestrator({
199
- spec: makePipelineSpec({
200
- depends_on_convoy: ['./a.yaml', './b.yaml'],
201
- on_failure: 'stop',
202
- }),
203
- specYaml: 'name: pipeline',
204
- adapter: makeAdapter(),
205
- dbPath,
206
- _createConvoyEngine: factory,
207
- _ensureBranch: async () => { },
208
- }).run();
209
- expect(result.status).toBe('failed');
210
- expect(result.summary.skipped).toBe(1);
211
- expect(factory).toHaveBeenCalledTimes(1);
212
- });
213
- });
214
- // ── 4. on_failure: 'continue' ────────────────────────────────────────────────
215
- describe('on_failure: continue', () => {
216
- it('runs all three convoys even when second fails', async () => {
217
- const r1 = makeConvoyResult({ convoyId: 'c1' }, 'done');
218
- const r2 = makeConvoyResult({ convoyId: 'c2' }, 'failed');
219
- const r3 = makeConvoyResult({ convoyId: 'c3' }, 'done');
220
- const factory = makeEngineFactory([r1, r2, r3]);
221
- const result = await createPipelineOrchestrator({
222
- spec: makePipelineSpec({
223
- depends_on_convoy: ['./a.yaml', './b.yaml', './c.yaml'],
224
- on_failure: 'continue',
225
- }),
226
- specYaml: 'name: pipeline',
227
- adapter: makeAdapter(),
228
- dbPath,
229
- _createConvoyEngine: factory,
230
- _ensureBranch: async () => { },
231
- }).run();
232
- expect(result.status).toBe('failed');
233
- expect(result.summary.totalConvoys).toBe(3);
234
- expect(result.summary.completed).toBe(2);
235
- expect(result.summary.failed).toBe(1);
236
- expect(result.summary.skipped).toBe(0);
237
- expect(factory).toHaveBeenCalledTimes(3);
238
- });
239
- });
240
- // ── 5. Hybrid pipeline ────────────────────────────────────────────────────────
241
- describe('hybrid pipeline (chained + own tasks)', () => {
242
- it('runs chained convoys then own tasks as a final convoy', async () => {
243
- const r1 = makeConvoyResult({ convoyId: 'chained-1' });
244
- const rHybrid = makeConvoyResult({ convoyId: 'hybrid-own' });
245
- const factory = makeEngineFactory([r1, rHybrid]);
246
- const result = await createPipelineOrchestrator({
247
- spec: makePipelineSpec({
248
- depends_on_convoy: ['./a.yaml'],
249
- tasks: [makeTask()],
250
- }),
251
- specYaml: 'name: hybrid',
252
- adapter: makeAdapter(),
253
- dbPath,
254
- _createConvoyEngine: factory,
255
- _ensureBranch: async () => { },
256
- }).run();
257
- expect(result.status).toBe('done');
258
- expect(result.convoyResults).toHaveLength(2);
259
- expect(result.summary.totalConvoys).toBe(2);
260
- expect(factory).toHaveBeenCalledTimes(2);
261
- });
262
- it('does NOT run own tasks when pipeline is halted by on_failure: stop', async () => {
263
- const r1 = makeConvoyResult({ convoyId: 'c1' }, 'failed');
264
- const factory = makeEngineFactory([r1]);
265
- const result = await createPipelineOrchestrator({
266
- spec: makePipelineSpec({
267
- depends_on_convoy: ['./a.yaml'],
268
- tasks: [makeTask()],
269
- on_failure: 'stop',
270
- }),
271
- specYaml: 'name: hybrid',
272
- adapter: makeAdapter(),
273
- dbPath,
274
- _createConvoyEngine: factory,
275
- _ensureBranch: async () => { },
276
- }).run();
277
- expect(result.summary.totalConvoys).toBe(1);
278
- expect(factory).toHaveBeenCalledTimes(1);
279
- expect(result.status).toBe('failed');
280
- });
281
- });
282
- // ── 6. Token aggregation ──────────────────────────────────────────────────────
283
- describe('token aggregation', () => {
284
- it('sums total_tokens across all convoy results', async () => {
285
- const r1 = makeConvoyResult({ convoyId: 'c1', cost: { total_tokens: 100 } });
286
- const r2 = makeConvoyResult({ convoyId: 'c2', cost: { total_tokens: 250 } });
287
- const factory = makeEngineFactory([r1, r2]);
288
- const result = await createPipelineOrchestrator({
289
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml', './b.yaml'] }),
290
- specYaml: 'name: pipeline',
291
- adapter: makeAdapter(),
292
- dbPath,
293
- _createConvoyEngine: factory,
294
- _ensureBranch: async () => { },
295
- }).run();
296
- expect(result.cost?.total_tokens).toBe(350);
297
- });
298
- it('omits cost when no convoy has token data', async () => {
299
- const factory = makeEngineFactory([makeConvoyResult()]); // no cost field
300
- const result = await createPipelineOrchestrator({
301
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
302
- specYaml: 'name: pipeline',
303
- adapter: makeAdapter(),
304
- dbPath,
305
- _createConvoyEngine: factory,
306
- _ensureBranch: async () => { },
307
- }).run();
308
- expect(result.cost).toBeUndefined();
309
- });
310
- it('persists total_tokens in the pipeline SQLite record', async () => {
311
- const factory = makeEngineFactory([
312
- makeConvoyResult({ cost: { total_tokens: 42 } }),
313
- ]);
314
- const result = await createPipelineOrchestrator({
315
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
316
- specYaml: 'name: pipeline',
317
- adapter: makeAdapter(),
318
- dbPath,
319
- _createConvoyEngine: factory,
320
- _ensureBranch: async () => { },
321
- }).run();
322
- const store = createConvoyStore(dbPath);
323
- const record = store.getPipeline(result.pipelineId);
324
- store.close();
325
- expect(record.total_tokens).toBe(42);
326
- });
327
- });
328
- // ── 7. Shared branch ──────────────────────────────────────────────────────────
329
- describe('shared branch', () => {
330
- it('passes the pipeline branch to all convoy engines', async () => {
331
- const factory = makeEngineFactory([makeConvoyResult(), makeConvoyResult()]);
332
- await createPipelineOrchestrator({
333
- spec: makePipelineSpec({
334
- branch: 'feature/pipeline-test',
335
- depends_on_convoy: ['./a.yaml', './b.yaml'],
336
- }),
337
- specYaml: 'name: pipeline',
338
- adapter: makeAdapter(),
339
- dbPath,
340
- _createConvoyEngine: factory,
341
- _ensureBranch: async () => { },
342
- }).run();
343
- const calls = factory.mock.calls;
344
- expect(calls[0][0].spec.branch).toBe('feature/pipeline-test');
345
- expect(calls[1][0].spec.branch).toBe('feature/pipeline-test');
346
- });
347
- });
348
- // ── 8. Pipeline convoy linking ────────────────────────────────────────────────
349
- describe('pipeline convoy linking', () => {
350
- it('passes pipelineId to each convoy engine', async () => {
351
- const factory = makeEngineFactory([makeConvoyResult(), makeConvoyResult()]);
352
- const result = await createPipelineOrchestrator({
353
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml', './b.yaml'] }),
354
- specYaml: 'name: pipeline',
355
- adapter: makeAdapter(),
356
- dbPath,
357
- _createConvoyEngine: factory,
358
- _ensureBranch: async () => { },
359
- }).run();
360
- const calls = factory.mock.calls;
361
- expect(calls[0][0].pipelineId).toBe(result.pipelineId);
362
- expect(calls[1][0].pipelineId).toBe(result.pipelineId);
363
- });
364
- });
365
- // ── 9. Pipeline record persistence transitions ────────────────────────────────
366
- describe('pipeline record persistence', () => {
367
- it('transitions: pending → running → done', async () => {
368
- let statusDuringRun;
369
- const factory = vi.fn((_opts) => ({
370
- run: vi.fn().mockImplementation(async () => {
371
- const s = createConvoyStore(dbPath);
372
- statusDuringRun = s.getPipeline(_opts.pipelineId)?.status;
373
- s.close();
374
- return makeConvoyResult();
375
- }),
376
- resume: vi.fn(),
377
- retryFailed: vi.fn(),
378
- injectTask: vi.fn(),
379
- }));
380
- const result = await createPipelineOrchestrator({
381
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
382
- specYaml: 'name: pipeline',
383
- adapter: makeAdapter(),
384
- dbPath,
385
- _createConvoyEngine: factory,
386
- _ensureBranch: async () => { },
387
- }).run();
388
- expect(statusDuringRun).toBe('running');
389
- const store = createConvoyStore(dbPath);
390
- const record = store.getPipeline(result.pipelineId);
391
- store.close();
392
- expect(record.status).toBe('done');
393
- expect(record.started_at).not.toBeNull();
394
- expect(record.finished_at).not.toBeNull();
395
- });
396
- it('marks pipeline as failed when a convoy fails', async () => {
397
- const factory = makeEngineFactory([makeConvoyResult({}, 'failed')]);
398
- const result = await createPipelineOrchestrator({
399
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
400
- specYaml: 'name: pipeline',
401
- adapter: makeAdapter(),
402
- dbPath,
403
- _createConvoyEngine: factory,
404
- _ensureBranch: async () => { },
405
- }).run();
406
- const store = createConvoyStore(dbPath);
407
- const record = store.getPipeline(result.pipelineId);
408
- store.close();
409
- expect(record.status).toBe('failed');
410
- });
411
- });
412
- // ── 10. Pipeline resume ───────────────────────────────────────────────────────
413
- describe('pipeline resume', () => {
414
- it('continues from the first non-completed convoy', async () => {
415
- const pipelineId = 'pipeline-resume-continue-test';
416
- const doneConvoyId = 'convoy-1-done';
417
- // Pre-seed the pipeline and a completed convoy directly in the store
418
- const store = createConvoyStore(dbPath);
419
- store.insertPipeline({
420
- id: pipelineId,
421
- name: 'Test Pipeline',
422
- status: 'running',
423
- branch: 'main',
424
- spec_yaml: 'name: pipeline',
425
- convoy_specs: JSON.stringify(['./a.yaml', './b.yaml']),
426
- created_at: new Date(Date.now() - 5000).toISOString(),
427
- });
428
- store.insertConvoy({
429
- id: doneConvoyId,
430
- name: 'Convoy A',
431
- spec_hash: 'abc',
432
- status: 'done',
433
- branch: 'main',
434
- created_at: new Date(Date.now() - 4000).toISOString(),
435
- spec_yaml: CONVOY_YAML,
436
- pipeline_id: pipelineId,
437
- });
438
- store.close();
439
- // Resume: second convoy is fresh, factory called once for ./b.yaml
440
- const secondResult = makeConvoyResult({ convoyId: 'convoy-2-fresh' }, 'done');
441
- const resumeFactory = makeEngineFactory([secondResult]);
442
- const pipelineSpec = makePipelineSpec({ depends_on_convoy: ['./a.yaml', './b.yaml'] });
443
- const resumeResult = await createPipelineOrchestrator({
444
- spec: pipelineSpec,
445
- specYaml: 'name: pipeline',
446
- adapter: makeAdapter(),
447
- dbPath,
448
- _createConvoyEngine: resumeFactory,
449
- _ensureBranch: async () => { },
450
- }).resume(pipelineId);
451
- expect(resumeResult.convoyResults).toHaveLength(2);
452
- expect(resumeResult.convoyResults[0].convoyId).toBe(doneConvoyId);
453
- expect(resumeResult.convoyResults[1].convoyId).toBe('convoy-2-fresh');
454
- // Only second convoy ran on resume
455
- expect(resumeFactory).toHaveBeenCalledTimes(1);
456
- });
457
- it('reconstructs token cost from done convoys during resume', async () => {
458
- const pipelineId = 'pipeline-resume-tokens';
459
- const doneConvoyId = 'convoy-done-with-tokens';
460
- const store = createConvoyStore(dbPath);
461
- store.insertPipeline({
462
- id: pipelineId,
463
- name: 'Token Pipeline',
464
- status: 'running',
465
- branch: 'main',
466
- spec_yaml: 'name: pipeline',
467
- convoy_specs: JSON.stringify(['./a.yaml']),
468
- created_at: new Date().toISOString(),
469
- });
470
- store.insertConvoy({
471
- id: doneConvoyId,
472
- name: 'Done Convoy',
473
- spec_hash: 'abc',
474
- status: 'done',
475
- branch: 'main',
476
- created_at: new Date().toISOString(),
477
- spec_yaml: CONVOY_YAML,
478
- pipeline_id: pipelineId,
479
- });
480
- store.updateConvoyStatus(doneConvoyId, 'done', { total_tokens: 77 });
481
- store.close();
482
- const resumeFactory = makeEngineFactory([]);
483
- const result = await createPipelineOrchestrator({
484
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
485
- specYaml: 'name: pipeline',
486
- adapter: makeAdapter(),
487
- dbPath,
488
- _createConvoyEngine: resumeFactory,
489
- _ensureBranch: async () => { },
490
- }).resume(pipelineId);
491
- expect(result.cost?.total_tokens).toBe(77);
492
- expect(result.convoyResults[0].cost).toEqual({ total_tokens: 77 });
493
- expect(resumeFactory).not.toHaveBeenCalled();
494
- });
495
- it('halts remaining convoys during resume when on_failure: stop', async () => {
496
- const pipelineId = 'pipeline-resume-halt';
497
- const store = createConvoyStore(dbPath);
498
- store.insertPipeline({
499
- id: pipelineId,
500
- name: 'Halt Pipeline',
501
- status: 'running',
502
- branch: 'main',
503
- spec_yaml: 'name: pipeline',
504
- convoy_specs: JSON.stringify(['./a.yaml', './b.yaml', './c.yaml']),
505
- created_at: new Date().toISOString(),
506
- });
507
- store.close();
508
- // First call fails, second should be skipped
509
- const failResult = makeConvoyResult({ convoyId: 'c1' }, 'failed');
510
- const resumeFactory = makeEngineFactory([failResult]);
511
- const result = await createPipelineOrchestrator({
512
- spec: makePipelineSpec({
513
- depends_on_convoy: ['./a.yaml', './b.yaml', './c.yaml'],
514
- on_failure: 'stop',
515
- }),
516
- specYaml: 'name: pipeline',
517
- adapter: makeAdapter(),
518
- dbPath,
519
- _createConvoyEngine: resumeFactory,
520
- _ensureBranch: async () => { },
521
- }).resume(pipelineId);
522
- expect(result.status).toBe('failed');
523
- expect(result.summary.skipped).toBe(2);
524
- expect(resumeFactory).toHaveBeenCalledTimes(1);
525
- });
526
- it('throws when pipelineId does not exist in store', async () => {
527
- const pipeline = createPipelineOrchestrator({
528
- spec: makePipelineSpec(),
529
- specYaml: 'name: pipeline',
530
- adapter: makeAdapter(),
531
- dbPath,
532
- _createConvoyEngine: makeEngineFactory([]),
533
- _ensureBranch: async () => { },
534
- });
535
- await expect(pipeline.resume('nonexistent-id')).rejects.toThrow('Pipeline "nonexistent-id" not found in store');
536
- });
537
- it('resumes a running convoy via engine.resume()', async () => {
538
- const pipelineId = 'pipeline-resume-test';
539
- const runningConvoyId = 'convoy-running-123';
540
- const store = createConvoyStore(dbPath);
541
- store.insertPipeline({
542
- id: pipelineId,
543
- name: 'Resume Test',
544
- status: 'running',
545
- branch: 'main',
546
- spec_yaml: 'name: resume',
547
- convoy_specs: JSON.stringify(['./a.yaml']),
548
- created_at: new Date(Date.now() - 1000).toISOString(),
549
- });
550
- store.insertConvoy({
551
- id: runningConvoyId,
552
- name: 'Convoy A',
553
- spec_hash: 'abc123',
554
- status: 'running',
555
- branch: 'main',
556
- created_at: new Date().toISOString(),
557
- spec_yaml: CONVOY_YAML,
558
- pipeline_id: pipelineId,
559
- });
560
- store.close();
561
- const resumedResult = makeConvoyResult({ convoyId: runningConvoyId }, 'done');
562
- const mockEngine = {
563
- run: vi.fn().mockResolvedValue(makeConvoyResult()),
564
- resume: vi.fn().mockResolvedValue(resumedResult),
565
- retryFailed: vi.fn(),
566
- injectTask: vi.fn(),
567
- };
568
- const factory = vi.fn().mockReturnValue(mockEngine);
569
- const result = await createPipelineOrchestrator({
570
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
571
- specYaml: 'name: pipeline',
572
- adapter: makeAdapter(),
573
- dbPath,
574
- _createConvoyEngine: factory,
575
- _ensureBranch: async () => { },
576
- }).resume(pipelineId);
577
- expect(mockEngine.resume).toHaveBeenCalledWith(runningConvoyId);
578
- expect(mockEngine.run).not.toHaveBeenCalled();
579
- expect(result.convoyResults[0].convoyId).toBe(runningConvoyId);
580
- });
581
- it('resumes a failed convoy via retryFailed + resume instead of running fresh', async () => {
582
- const pipelineId = 'pipeline-resume-failed-convoy';
583
- const failedConvoyId = 'convoy-failed-456';
584
- const store = createConvoyStore(dbPath);
585
- store.insertPipeline({
586
- id: pipelineId,
587
- name: 'Failed Resume Test',
588
- status: 'running',
589
- branch: 'main',
590
- spec_yaml: 'name: resume-failed',
591
- convoy_specs: JSON.stringify(['./a.yaml']),
592
- created_at: new Date(Date.now() - 1000).toISOString(),
593
- });
594
- store.insertConvoy({
595
- id: failedConvoyId,
596
- name: 'Convoy A',
597
- spec_hash: 'abc123',
598
- status: 'failed',
599
- branch: 'main',
600
- created_at: new Date().toISOString(),
601
- spec_yaml: CONVOY_YAML,
602
- pipeline_id: pipelineId,
603
- });
604
- store.close();
605
- const resumedResult = makeConvoyResult({ convoyId: failedConvoyId }, 'done');
606
- const mockEngine = {
607
- run: vi.fn().mockResolvedValue(makeConvoyResult()),
608
- resume: vi.fn().mockResolvedValue(resumedResult),
609
- retryFailed: vi.fn(),
610
- injectTask: vi.fn(),
611
- };
612
- const factory = vi.fn().mockReturnValue(mockEngine);
613
- const result = await createPipelineOrchestrator({
614
- spec: makePipelineSpec({ depends_on_convoy: ['./a.yaml'] }),
615
- specYaml: 'name: pipeline',
616
- adapter: makeAdapter(),
617
- dbPath,
618
- _createConvoyEngine: factory,
619
- _ensureBranch: async () => { },
620
- }).resume(pipelineId);
621
- expect(mockEngine.retryFailed).toHaveBeenCalledWith(failedConvoyId);
622
- expect(mockEngine.resume).toHaveBeenCalledWith(failedConvoyId);
623
- expect(mockEngine.run).not.toHaveBeenCalled();
624
- expect(result.convoyResults[0].convoyId).toBe(failedConvoyId);
625
- });
626
- });
627
- // ── 12. getCurrentBranch fallback ─────────────────────────────────────────────
628
- describe('getCurrentBranch fallback', () => {
629
- it('run() uses getCurrentBranch when spec has no branch (falls back to main)', async () => {
630
- const factory = makeEngineFactory([makeConvoyResult()]);
631
- // No branch on spec — forces getCurrentBranch call (git fails in tmpDir, returns 'main')
632
- const specNoBranch = {
633
- name: 'No Branch Pipeline',
634
- concurrency: 1,
635
- on_failure: 'continue',
636
- adapter: 'test',
637
- version: 2,
638
- depends_on_convoy: ['./a.yaml'],
639
- };
640
- const result = await createPipelineOrchestrator({
641
- spec: specNoBranch,
642
- specYaml: 'name: pipeline',
643
- adapter: makeAdapter(),
644
- basePath: tmpDir, // not a git repo → getCurrentBranch returns 'main'
645
- dbPath,
646
- _createConvoyEngine: factory,
647
- _ensureBranch: async () => { },
648
- }).run();
649
- expect(result.status).toBe('done');
650
- // branch should be whatever getCurrentBranch returns (likely 'main' or 'HEAD')
651
- const store = createConvoyStore(dbPath);
652
- const record = store.getPipeline(result.pipelineId);
653
- store.close();
654
- expect(typeof record.branch).toBe('string');
655
- });
656
- it('resume() uses getCurrentBranch when pipeline branch is null and spec has no branch', async () => {
657
- const pipelineId = 'pipeline-no-branch';
658
- const store = createConvoyStore(dbPath);
659
- store.insertPipeline({
660
- id: pipelineId,
661
- name: 'No Branch Resume',
662
- status: 'running',
663
- branch: null,
664
- spec_yaml: 'name: pipeline',
665
- convoy_specs: JSON.stringify(['./a.yaml']),
666
- created_at: new Date().toISOString(),
667
- });
668
- store.close();
669
- const resumeFactory = makeEngineFactory([makeConvoyResult()]);
670
- const specNoBranch = {
671
- name: 'No Branch Pipeline',
672
- concurrency: 1,
673
- on_failure: 'continue',
674
- adapter: 'test',
675
- version: 2,
676
- depends_on_convoy: ['./a.yaml'],
677
- };
678
- const result = await createPipelineOrchestrator({
679
- spec: specNoBranch,
680
- specYaml: 'name: pipeline',
681
- adapter: makeAdapter(),
682
- basePath: tmpDir,
683
- dbPath,
684
- _createConvoyEngine: resumeFactory,
685
- _ensureBranch: async () => { },
686
- }).resume(pipelineId);
687
- expect(result.status).toBe('done');
688
- });
689
- });
690
- // ── 13. Path traversal protection ────────────────────────────────────────────
691
- describe('path traversal protection', () => {
692
- it('rejects absolute path in depends_on_convoy', async () => {
693
- const factory = makeEngineFactory([]);
694
- const result = await createPipelineOrchestrator({
695
- spec: makePipelineSpec({ depends_on_convoy: ['/etc/passwd'] }),
696
- specYaml: 'name: pipeline',
697
- adapter: makeAdapter(),
698
- dbPath,
699
- _createConvoyEngine: factory,
700
- _ensureBranch: async () => { },
701
- }).run();
702
- expect(result.status).toBe('failed');
703
- expect(result.summary.failed).toBe(1);
704
- expect(result.convoyResults[0].status).toBe('failed');
705
- // Engine should never be called — error happens before spec is loaded
706
- expect(factory).not.toHaveBeenCalled();
707
- // Pipeline record must be finalized (not stuck in 'running')
708
- const store = createConvoyStore(dbPath);
709
- const record = store.getPipeline(result.pipelineId);
710
- store.close();
711
- expect(record.status).toBe('failed');
712
- expect(record.finished_at).not.toBeNull();
713
- });
714
- it('rejects path traversal via .. in depends_on_convoy', async () => {
715
- const factory = makeEngineFactory([]);
716
- const result = await createPipelineOrchestrator({
717
- spec: makePipelineSpec({ depends_on_convoy: ['../../etc/passwd'] }),
718
- specYaml: 'name: pipeline',
719
- adapter: makeAdapter(),
720
- dbPath,
721
- _createConvoyEngine: factory,
722
- _ensureBranch: async () => { },
723
- }).run();
724
- expect(result.status).toBe('failed');
725
- expect(result.summary.failed).toBe(1);
726
- expect(result.convoyResults[0].status).toBe('failed');
727
- expect(factory).not.toHaveBeenCalled();
728
- // Pipeline record must be finalized
729
- const store = createConvoyStore(dbPath);
730
- const record = store.getPipeline(result.pipelineId);
731
- store.close();
732
- expect(record.status).toBe('failed');
733
- expect(record.finished_at).not.toBeNull();
734
- });
735
- it('allows valid relative path like ./sub/convoy.yaml', async () => {
736
- // readFile default mock returns CONVOY_YAML for any path
737
- const factory = makeEngineFactory([makeConvoyResult()]);
738
- const result = await createPipelineOrchestrator({
739
- spec: makePipelineSpec({ depends_on_convoy: ['./sub/convoy.yaml'] }),
740
- specYaml: 'name: pipeline',
741
- adapter: makeAdapter(),
742
- dbPath,
743
- _createConvoyEngine: factory,
744
- _ensureBranch: async () => { },
745
- }).run();
746
- expect(result.status).toBe('done');
747
- expect(factory).toHaveBeenCalledTimes(1);
748
- });
749
- });
750
- // ── 14. Missing convoy spec file ──────────────────────────────────────────────
751
- describe('missing convoy spec file', () => {
752
- it('handles readFile ENOENT without crashing pipeline (on_failure: continue)', async () => {
753
- const enoentError = Object.assign(new Error('ENOENT: no such file or directory'), {
754
- code: 'ENOENT',
755
- });
756
- // First call (./missing.yaml) rejects; second (./exists.yaml) falls back to default CONVOY_YAML
757
- vi.mocked(readFile).mockRejectedValueOnce(enoentError);
758
- const factory = makeEngineFactory([makeConvoyResult({ convoyId: 'exists-convoy' })]);
759
- const result = await createPipelineOrchestrator({
760
- spec: makePipelineSpec({
761
- depends_on_convoy: ['./missing.yaml', './exists.yaml'],
762
- on_failure: 'continue',
763
- }),
764
- specYaml: 'name: pipeline',
765
- adapter: makeAdapter(),
766
- dbPath,
767
- _createConvoyEngine: factory,
768
- _ensureBranch: async () => { },
769
- }).run();
770
- expect(result.status).toBe('failed');
771
- expect(result.summary.failed).toBeGreaterThanOrEqual(1);
772
- expect(result.summary.completed).toBeGreaterThanOrEqual(1);
773
- // Engine only called once — for the second spec (first failed before engine)
774
- expect(factory).toHaveBeenCalledTimes(1);
775
- // Pipeline record finalized (not stuck in 'running')
776
- const store = createConvoyStore(dbPath);
777
- const record = store.getPipeline(result.pipelineId);
778
- store.close();
779
- expect(record.status).toBe('failed');
780
- expect(record.finished_at).not.toBeNull();
781
- });
782
- it('stops pipeline on missing file when on_failure: stop', async () => {
783
- const enoentError = Object.assign(new Error('ENOENT: no such file or directory'), {
784
- code: 'ENOENT',
785
- });
786
- vi.mocked(readFile).mockRejectedValueOnce(enoentError);
787
- const factory = makeEngineFactory([makeConvoyResult()]);
788
- const result = await createPipelineOrchestrator({
789
- spec: makePipelineSpec({
790
- depends_on_convoy: ['./missing.yaml', './exists.yaml'],
791
- on_failure: 'stop',
792
- }),
793
- specYaml: 'name: pipeline',
794
- adapter: makeAdapter(),
795
- dbPath,
796
- _createConvoyEngine: factory,
797
- _ensureBranch: async () => { },
798
- }).run();
799
- expect(result.status).toBe('failed');
800
- expect(result.summary.skipped).toBeGreaterThanOrEqual(1);
801
- // Second spec skipped — factory never called
802
- expect(factory).not.toHaveBeenCalled();
803
- // Pipeline record finalized as failed
804
- const store = createConvoyStore(dbPath);
805
- const record = store.getPipeline(result.pipelineId);
806
- store.close();
807
- expect(record.status).toBe('failed');
808
- expect(record.finished_at).not.toBeNull();
809
- });
810
- });
811
- // ── 15. Invalid convoy YAML ───────────────────────────────────────────────────
812
- describe('invalid convoy YAML', () => {
813
- it('handles parse error without crashing pipeline', async () => {
814
- // Return syntactically broken YAML (unclosed bracket triggers YAMLException)
815
- vi.mocked(readFile).mockResolvedValueOnce('name: [unclosed bracket');
816
- const factory = makeEngineFactory([]);
817
- const result = await createPipelineOrchestrator({
818
- spec: makePipelineSpec({ depends_on_convoy: ['./bad.yaml'] }),
819
- specYaml: 'name: pipeline',
820
- adapter: makeAdapter(),
821
- dbPath,
822
- _createConvoyEngine: factory,
823
- _ensureBranch: async () => { },
824
- }).run();
825
- expect(result.status).toBe('failed');
826
- expect(result.summary.failed).toBeGreaterThanOrEqual(1);
827
- // Engine never called — parse error happens before engine creation
828
- expect(factory).not.toHaveBeenCalled();
829
- // Pipeline record finalized (not stuck in 'running')
830
- const store = createConvoyStore(dbPath);
831
- const record = store.getPipeline(result.pipelineId);
832
- store.close();
833
- expect(record.status).toBe('failed');
834
- expect(record.finished_at).not.toBeNull();
835
- });
836
- });
837
- //# sourceMappingURL=pipeline.test.js.map