oh-my-copilot 5.18.2 → 5.19.2

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 (326) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +206 -104
  4. package/bridge/__pycache__/gyoshu_bridge.cpython-314.pyc +0 -0
  5. package/bridge/claude-md-coordinator.cjs +2 -2
  6. package/bridge/cli.cjs +7155 -4471
  7. package/bridge/mcp-server.cjs +2470 -1027
  8. package/bridge/runtime-cli.cjs +102 -12
  9. package/bridge/team-mcp.cjs +100 -11
  10. package/bridge/team.js +100 -11
  11. package/dist/budget/ledger.d.ts +5 -0
  12. package/dist/budget/ledger.d.ts.map +1 -1
  13. package/dist/budget/ledger.js +2 -1
  14. package/dist/budget/ledger.js.map +1 -1
  15. package/dist/cli/commands/__tests__/factory-forge-cli.test.js +3 -3
  16. package/dist/cli/commands/__tests__/factory-forge-cli.test.js.map +1 -1
  17. package/dist/cli/commands/__tests__/factory-init.test.js +239 -17
  18. package/dist/cli/commands/__tests__/factory-init.test.js.map +1 -1
  19. package/dist/cli/commands/__tests__/factory-run-cli.test.js +103 -2
  20. package/dist/cli/commands/__tests__/factory-run-cli.test.js.map +1 -1
  21. package/dist/cli/commands/factory-board.d.ts +9 -0
  22. package/dist/cli/commands/factory-board.d.ts.map +1 -0
  23. package/dist/cli/commands/factory-board.js +34 -0
  24. package/dist/cli/commands/factory-board.js.map +1 -0
  25. package/dist/cli/commands/factory-check.d.ts +1 -0
  26. package/dist/cli/commands/factory-check.d.ts.map +1 -1
  27. package/dist/cli/commands/factory-check.js +2 -1
  28. package/dist/cli/commands/factory-check.js.map +1 -1
  29. package/dist/cli/commands/factory-poll.d.ts +9 -0
  30. package/dist/cli/commands/factory-poll.d.ts.map +1 -0
  31. package/dist/cli/commands/factory-poll.js +34 -0
  32. package/dist/cli/commands/factory-poll.js.map +1 -0
  33. package/dist/cli/commands/factory-setup.d.ts +2 -0
  34. package/dist/cli/commands/factory-setup.d.ts.map +1 -1
  35. package/dist/cli/commands/factory-setup.js +9 -3
  36. package/dist/cli/commands/factory-setup.js.map +1 -1
  37. package/dist/cli/commands/factory.d.ts +61 -18
  38. package/dist/cli/commands/factory.d.ts.map +1 -1
  39. package/dist/cli/commands/factory.js +325 -53
  40. package/dist/cli/commands/factory.js.map +1 -1
  41. package/dist/factory/__tests__/check-run.test.js +37 -96
  42. package/dist/factory/__tests__/check-run.test.js.map +1 -1
  43. package/dist/factory/__tests__/enqueue-ado.test.d.ts +2 -0
  44. package/dist/factory/__tests__/enqueue-ado.test.d.ts.map +1 -0
  45. package/dist/factory/__tests__/enqueue-ado.test.js +375 -0
  46. package/dist/factory/__tests__/enqueue-ado.test.js.map +1 -0
  47. package/dist/factory/__tests__/enqueue.test.d.ts +2 -0
  48. package/dist/factory/__tests__/enqueue.test.d.ts.map +1 -0
  49. package/dist/factory/__tests__/enqueue.test.js +470 -0
  50. package/dist/factory/__tests__/enqueue.test.js.map +1 -0
  51. package/dist/factory/__tests__/heal-ado.test.d.ts +2 -0
  52. package/dist/factory/__tests__/heal-ado.test.d.ts.map +1 -0
  53. package/dist/factory/__tests__/heal-ado.test.js +237 -0
  54. package/dist/factory/__tests__/heal-ado.test.js.map +1 -0
  55. package/dist/factory/__tests__/listener.test.js +27 -9
  56. package/dist/factory/__tests__/listener.test.js.map +1 -1
  57. package/dist/factory/__tests__/map-frontier.test.js +68 -0
  58. package/dist/factory/__tests__/map-frontier.test.js.map +1 -1
  59. package/dist/factory/__tests__/map-ingest.test.js +4 -3
  60. package/dist/factory/__tests__/map-ingest.test.js.map +1 -1
  61. package/dist/factory/__tests__/poll-ado.test.d.ts +2 -0
  62. package/dist/factory/__tests__/poll-ado.test.d.ts.map +1 -0
  63. package/dist/factory/__tests__/poll-ado.test.js +263 -0
  64. package/dist/factory/__tests__/poll-ado.test.js.map +1 -0
  65. package/dist/factory/__tests__/poll.test.d.ts +2 -0
  66. package/dist/factory/__tests__/poll.test.d.ts.map +1 -0
  67. package/dist/factory/__tests__/poll.test.js +748 -0
  68. package/dist/factory/__tests__/poll.test.js.map +1 -0
  69. package/dist/factory/board/__tests__/board-ado.test.d.ts +2 -0
  70. package/dist/factory/board/__tests__/board-ado.test.d.ts.map +1 -0
  71. package/dist/factory/board/__tests__/board-ado.test.js +194 -0
  72. package/dist/factory/board/__tests__/board-ado.test.js.map +1 -0
  73. package/dist/factory/board/__tests__/board.test.d.ts +2 -0
  74. package/dist/factory/board/__tests__/board.test.d.ts.map +1 -0
  75. package/dist/factory/board/__tests__/board.test.js +287 -0
  76. package/dist/factory/board/__tests__/board.test.js.map +1 -0
  77. package/dist/factory/board/collect.d.ts +145 -0
  78. package/dist/factory/board/collect.d.ts.map +1 -0
  79. package/dist/factory/board/collect.js +330 -0
  80. package/dist/factory/board/collect.js.map +1 -0
  81. package/dist/factory/board/render.d.ts +12 -0
  82. package/dist/factory/board/render.d.ts.map +1 -0
  83. package/dist/factory/board/render.js +93 -0
  84. package/dist/factory/board/render.js.map +1 -0
  85. package/dist/factory/check/__tests__/ado.test.js +14 -1
  86. package/dist/factory/check/__tests__/ado.test.js.map +1 -1
  87. package/dist/factory/check/__tests__/cli.test.js +38 -0
  88. package/dist/factory/check/__tests__/cli.test.js.map +1 -1
  89. package/dist/factory/check/__tests__/rules.test.js +72 -2
  90. package/dist/factory/check/__tests__/rules.test.js.map +1 -1
  91. package/dist/factory/check/cli.d.ts +34 -6
  92. package/dist/factory/check/cli.d.ts.map +1 -1
  93. package/dist/factory/check/cli.js +56 -34
  94. package/dist/factory/check/cli.js.map +1 -1
  95. package/dist/factory/check/rules.d.ts +11 -3
  96. package/dist/factory/check/rules.d.ts.map +1 -1
  97. package/dist/factory/check/rules.js +18 -5
  98. package/dist/factory/check/rules.js.map +1 -1
  99. package/dist/factory/check/score.d.ts +22 -2
  100. package/dist/factory/check/score.d.ts.map +1 -1
  101. package/dist/factory/check/score.js +55 -1
  102. package/dist/factory/check/score.js.map +1 -1
  103. package/dist/factory/enqueue.d.ts +195 -0
  104. package/dist/factory/enqueue.d.ts.map +1 -0
  105. package/dist/factory/enqueue.js +788 -0
  106. package/dist/factory/enqueue.js.map +1 -0
  107. package/dist/factory/heal/cli.d.ts +34 -2
  108. package/dist/factory/heal/cli.d.ts.map +1 -1
  109. package/dist/factory/heal/cli.js +88 -19
  110. package/dist/factory/heal/cli.js.map +1 -1
  111. package/dist/factory/heal/history.d.ts +12 -6
  112. package/dist/factory/heal/history.d.ts.map +1 -1
  113. package/dist/factory/heal/history.js +16 -6
  114. package/dist/factory/heal/history.js.map +1 -1
  115. package/dist/factory/heal/implement.d.ts +3 -1
  116. package/dist/factory/heal/implement.d.ts.map +1 -1
  117. package/dist/factory/heal/implement.js +1 -0
  118. package/dist/factory/heal/implement.js.map +1 -1
  119. package/dist/factory/heal/run.d.ts +3 -0
  120. package/dist/factory/heal/run.d.ts.map +1 -1
  121. package/dist/factory/heal/run.js +1 -1
  122. package/dist/factory/heal/run.js.map +1 -1
  123. package/dist/factory/listener.d.ts +13 -17
  124. package/dist/factory/listener.d.ts.map +1 -1
  125. package/dist/factory/listener.js +37 -63
  126. package/dist/factory/listener.js.map +1 -1
  127. package/dist/factory/map-frontier.d.ts +8 -1
  128. package/dist/factory/map-frontier.d.ts.map +1 -1
  129. package/dist/factory/map-frontier.js +65 -5
  130. package/dist/factory/map-frontier.js.map +1 -1
  131. package/dist/factory/map-ingest.d.ts.map +1 -1
  132. package/dist/factory/map-ingest.js +12 -1
  133. package/dist/factory/map-ingest.js.map +1 -1
  134. package/dist/factory/poll.d.ts +308 -0
  135. package/dist/factory/poll.d.ts.map +1 -0
  136. package/dist/factory/poll.js +677 -0
  137. package/dist/factory/poll.js.map +1 -0
  138. package/dist/factory/run/__tests__/engine.ado.test.js +157 -8
  139. package/dist/factory/run/__tests__/engine.ado.test.js.map +1 -1
  140. package/dist/factory/run/__tests__/engine.outcome.test.d.ts +2 -0
  141. package/dist/factory/run/__tests__/engine.outcome.test.d.ts.map +1 -0
  142. package/dist/factory/run/__tests__/engine.outcome.test.js +223 -0
  143. package/dist/factory/run/__tests__/engine.outcome.test.js.map +1 -0
  144. package/dist/factory/run/__tests__/engine.test.js +91 -0
  145. package/dist/factory/run/__tests__/engine.test.js.map +1 -1
  146. package/dist/factory/run/__tests__/units.test.js +299 -2
  147. package/dist/factory/run/__tests__/units.test.js.map +1 -1
  148. package/dist/factory/run/engine.d.ts +11 -3
  149. package/dist/factory/run/engine.d.ts.map +1 -1
  150. package/dist/factory/run/engine.js +145 -22
  151. package/dist/factory/run/engine.js.map +1 -1
  152. package/dist/factory/run/exec.d.ts +32 -4
  153. package/dist/factory/run/exec.d.ts.map +1 -1
  154. package/dist/factory/run/exec.js +120 -15
  155. package/dist/factory/run/exec.js.map +1 -1
  156. package/dist/factory/run/outcome.d.ts +31 -0
  157. package/dist/factory/run/outcome.d.ts.map +1 -0
  158. package/dist/factory/run/outcome.js +70 -0
  159. package/dist/factory/run/outcome.js.map +1 -0
  160. package/dist/factory/run/review-output.d.ts +6 -1
  161. package/dist/factory/run/review-output.d.ts.map +1 -1
  162. package/dist/factory/run/review-output.js +13 -3
  163. package/dist/factory/run/review-output.js.map +1 -1
  164. package/dist/factory/run/state.d.ts +2 -0
  165. package/dist/factory/run/state.d.ts.map +1 -1
  166. package/dist/factory/run/state.js.map +1 -1
  167. package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts +2 -0
  168. package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts.map +1 -0
  169. package/dist/factory/setup/__tests__/pipeline-pick.test.js +84 -0
  170. package/dist/factory/setup/__tests__/pipeline-pick.test.js.map +1 -0
  171. package/dist/factory/setup/__tests__/setup.test.js +1 -0
  172. package/dist/factory/setup/__tests__/setup.test.js.map +1 -1
  173. package/dist/factory/setup/detect.js +1 -1
  174. package/dist/factory/setup/detect.js.map +1 -1
  175. package/dist/factory/setup/pipeline-pick.d.ts +25 -0
  176. package/dist/factory/setup/pipeline-pick.d.ts.map +1 -0
  177. package/dist/factory/setup/pipeline-pick.js +55 -0
  178. package/dist/factory/setup/pipeline-pick.js.map +1 -0
  179. package/dist/factory/setup/write.d.ts +6 -0
  180. package/dist/factory/setup/write.d.ts.map +1 -1
  181. package/dist/factory/setup/write.js +3 -1
  182. package/dist/factory/setup/write.js.map +1 -1
  183. package/dist/factory/watchdog.d.ts +3 -2
  184. package/dist/factory/watchdog.d.ts.map +1 -1
  185. package/dist/factory/watchdog.js +5 -4
  186. package/dist/factory/watchdog.js.map +1 -1
  187. package/dist/factory/watchdog.test.js +19 -4
  188. package/dist/factory/watchdog.test.js.map +1 -1
  189. package/dist/forge/__tests__/config.test.js +51 -0
  190. package/dist/forge/__tests__/config.test.js.map +1 -1
  191. package/dist/forge/__tests__/gh-argv-baseline.chain.test.js +2 -2
  192. package/dist/forge/__tests__/gh-argv-baseline.chain.test.js.map +1 -1
  193. package/dist/forge/__tests__/gh-argv-baseline.factory.test.js +6 -4
  194. package/dist/forge/__tests__/gh-argv-baseline.factory.test.js.map +1 -1
  195. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts +2 -0
  196. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts.map +1 -0
  197. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js +100 -0
  198. package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js.map +1 -0
  199. package/dist/forge/ado/__tests__/acceptance-scripts.test.js +360 -30
  200. package/dist/forge/ado/__tests__/acceptance-scripts.test.js.map +1 -1
  201. package/dist/forge/ado/__tests__/adapter.test.js +18 -3
  202. package/dist/forge/ado/__tests__/adapter.test.js.map +1 -1
  203. package/dist/forge/ado/__tests__/ci.test.d.ts +2 -0
  204. package/dist/forge/ado/__tests__/ci.test.d.ts.map +1 -0
  205. package/dist/forge/ado/__tests__/ci.test.js +271 -0
  206. package/dist/forge/ado/__tests__/ci.test.js.map +1 -0
  207. package/dist/forge/ado/__tests__/routes.test.js +24 -5
  208. package/dist/forge/ado/__tests__/routes.test.js.map +1 -1
  209. package/dist/forge/ado/__tests__/tracker-writes.test.d.ts +8 -0
  210. package/dist/forge/ado/__tests__/tracker-writes.test.d.ts.map +1 -0
  211. package/dist/forge/ado/__tests__/tracker-writes.test.js +377 -0
  212. package/dist/forge/ado/__tests__/tracker-writes.test.js.map +1 -0
  213. package/dist/forge/ado/__tests__/world.d.ts +4 -0
  214. package/dist/forge/ado/__tests__/world.d.ts.map +1 -1
  215. package/dist/forge/ado/__tests__/world.js +3 -2
  216. package/dist/forge/ado/__tests__/world.js.map +1 -1
  217. package/dist/forge/ado/checks.d.ts +25 -2
  218. package/dist/forge/ado/checks.d.ts.map +1 -1
  219. package/dist/forge/ado/checks.js +47 -23
  220. package/dist/forge/ado/checks.js.map +1 -1
  221. package/dist/forge/ado/ci.d.ts +13 -0
  222. package/dist/forge/ado/ci.d.ts.map +1 -0
  223. package/dist/forge/ado/ci.js +134 -0
  224. package/dist/forge/ado/ci.js.map +1 -0
  225. package/dist/forge/ado/guard.d.ts +19 -6
  226. package/dist/forge/ado/guard.d.ts.map +1 -1
  227. package/dist/forge/ado/guard.js +52 -11
  228. package/dist/forge/ado/guard.js.map +1 -1
  229. package/dist/forge/ado/index.d.ts +7 -1
  230. package/dist/forge/ado/index.d.ts.map +1 -1
  231. package/dist/forge/ado/index.js +16 -3
  232. package/dist/forge/ado/index.js.map +1 -1
  233. package/dist/forge/ado/reviews.d.ts +9 -1
  234. package/dist/forge/ado/reviews.d.ts.map +1 -1
  235. package/dist/forge/ado/reviews.js +45 -1
  236. package/dist/forge/ado/reviews.js.map +1 -1
  237. package/dist/forge/ado/routes.d.ts +35 -5
  238. package/dist/forge/ado/routes.d.ts.map +1 -1
  239. package/dist/forge/ado/routes.js +181 -9
  240. package/dist/forge/ado/routes.js.map +1 -1
  241. package/dist/forge/ado/tracker.d.ts +13 -2
  242. package/dist/forge/ado/tracker.d.ts.map +1 -1
  243. package/dist/forge/ado/tracker.js +139 -3
  244. package/dist/forge/ado/tracker.js.map +1 -1
  245. package/dist/forge/ado/wiql.d.ts +2 -0
  246. package/dist/forge/ado/wiql.d.ts.map +1 -1
  247. package/dist/forge/ado/wiql.js +6 -0
  248. package/dist/forge/ado/wiql.js.map +1 -1
  249. package/dist/forge/body-file.d.ts +17 -0
  250. package/dist/forge/body-file.d.ts.map +1 -0
  251. package/dist/forge/body-file.js +59 -0
  252. package/dist/forge/body-file.js.map +1 -0
  253. package/dist/forge/config.d.ts +3 -1
  254. package/dist/forge/config.d.ts.map +1 -1
  255. package/dist/forge/config.js +37 -2
  256. package/dist/forge/config.js.map +1 -1
  257. package/dist/forge/github/__tests__/argv-parity.test.js +17 -1
  258. package/dist/forge/github/__tests__/argv-parity.test.js.map +1 -1
  259. package/dist/forge/github/gh.d.ts +6 -0
  260. package/dist/forge/github/gh.d.ts.map +1 -1
  261. package/dist/forge/github/gh.js +2 -0
  262. package/dist/forge/github/gh.js.map +1 -1
  263. package/dist/forge/github/reviews.d.ts +2 -0
  264. package/dist/forge/github/reviews.d.ts.map +1 -1
  265. package/dist/forge/github/reviews.js +6 -0
  266. package/dist/forge/github/reviews.js.map +1 -1
  267. package/dist/forge/github/tracker.d.ts +20 -4
  268. package/dist/forge/github/tracker.d.ts.map +1 -1
  269. package/dist/forge/github/tracker.js +59 -5
  270. package/dist/forge/github/tracker.js.map +1 -1
  271. package/dist/forge/types.d.ts +108 -2
  272. package/dist/forge/types.d.ts.map +1 -1
  273. package/dist/forge/types.js +8 -0
  274. package/dist/forge/types.js.map +1 -1
  275. package/dist/graph/schema.d.ts +10 -10
  276. package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js +156 -35
  277. package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js.map +1 -1
  278. package/dist/hooks/session-end/__tests__/check-evidence.test.js +4 -4
  279. package/dist/hooks/session-end/__tests__/check-evidence.test.js.map +1 -1
  280. package/dist/hooks/session-end/__tests__/copilot-liveness.test.js +3 -3
  281. package/dist/hooks/session-end/__tests__/copilot-liveness.test.js.map +1 -1
  282. package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js +3 -3
  283. package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js.map +1 -1
  284. package/dist/hooks/session-end/__tests__/routing.test.js +36 -1
  285. package/dist/hooks/session-end/__tests__/routing.test.js.map +1 -1
  286. package/dist/hooks/session-end/__tests__/spawn-next.test.js +96 -5
  287. package/dist/hooks/session-end/__tests__/spawn-next.test.js.map +1 -1
  288. package/dist/hooks/session-end/__tests__/worker.test.js +38 -2
  289. package/dist/hooks/session-end/__tests__/worker.test.js.map +1 -1
  290. package/dist/hooks/session-end/chain-enqueuer.d.ts.map +1 -1
  291. package/dist/hooks/session-end/chain-enqueuer.js +22 -2
  292. package/dist/hooks/session-end/chain-enqueuer.js.map +1 -1
  293. package/dist/hooks/session-end/routing.d.ts +14 -0
  294. package/dist/hooks/session-end/routing.d.ts.map +1 -1
  295. package/dist/hooks/session-end/routing.js +25 -0
  296. package/dist/hooks/session-end/routing.js.map +1 -1
  297. package/dist/hooks/session-end/spawn-next.d.ts +20 -2
  298. package/dist/hooks/session-end/spawn-next.d.ts.map +1 -1
  299. package/dist/hooks/session-end/spawn-next.js +72 -5
  300. package/dist/hooks/session-end/spawn-next.js.map +1 -1
  301. package/dist/smoke/__tests__/copilot-chain-scenario.test.js +2 -1
  302. package/dist/smoke/__tests__/copilot-chain-scenario.test.js.map +1 -1
  303. package/dist/smoke/copilot-chain-scenario.d.ts.map +1 -1
  304. package/dist/smoke/copilot-chain-scenario.js +5 -1
  305. package/dist/smoke/copilot-chain-scenario.js.map +1 -1
  306. package/dist/team/__tests__/worker-launch-ack.test.js +134 -5
  307. package/dist/team/__tests__/worker-launch-ack.test.js.map +1 -1
  308. package/dist/team/worker-launch-ack.d.ts.map +1 -1
  309. package/dist/team/worker-launch-ack.js +19 -4
  310. package/dist/team/worker-launch-ack.js.map +1 -1
  311. package/docs/CLAUDE.md +1 -1
  312. package/docs/MIGRATION.md +26 -0
  313. package/docs/REFERENCE.md +187 -20
  314. package/docs/design/FACTORY-FINAL-DESIGN.md +1 -1
  315. package/docs/shipyard.md +17 -1
  316. package/package.json +2 -2
  317. package/plugin.json +1 -1
  318. package/scripts/ado-acceptance.mjs +309 -70
  319. package/scripts/lib/backlog-to-workitems.mjs +24 -21
  320. package/skills/ask-navigator/SKILL.md +5 -2
  321. package/skills/drydock/SKILL.md +2 -1
  322. package/skills/harbor/SKILL.md +17 -2
  323. package/skills/intent/SKILL.md +4 -0
  324. package/skills/launch/SKILL.md +35 -2
  325. package/skills/map/SKILL.md +2 -1
  326. package/skills/refit/SKILL.md +1 -0
@@ -4,15 +4,25 @@
4
4
  * throwaway Agile project per run, named `omg-acc-<yyyymmddHHMM>` (UTC):
5
5
  *
6
6
  * node scripts/ado-acceptance.mjs --org https://dev.azure.com/<org> --source C:/Code/ExcavatorTrek
7
- * [--phase preflight|create|exercise|heal-drill|capture|cleanup|all] [--run <runId>]
8
- * [--pool <self-hosted pool> | --hosted] [--with-lanes] [--project-id <guid>] [--dry-run]
7
+ * [--phase preflight|create|enqueue|exercise|heal-drill|capture|cleanup|all] [--run <runId>]
8
+ * [--pool <self-hosted pool> | --hosted] [--with-lanes] [--project-id <guid>] [--yes] [--dry-run]
9
9
  *
10
- * - `all` runs preflight, create, exercise and capture. `heal-drill` (it
11
- * needs a working agent and design PR C3) and `cleanup` run only by name.
10
+ * - `all` runs preflight, create, enqueue, exercise and capture. `heal-drill`
11
+ * (it needs a working agent and design PR C3) and `cleanup` run only by name.
12
+ * - The shipyard–factory flow (2026-10-30 integration design §3): `create`
13
+ * makes the spec work item, `enqueue` adds its creator to the user config's
14
+ * `factory.forge.azureDevOps.trustedAuthors` (printed, then confirmed) and
15
+ * hands the BACKLOG.md tickets to `omg factory enqueue` (`--dry-run` first,
16
+ * then for real once the dry run is signed), and `exercise` runs
17
+ * `omg factory run --next --parent <spec>`. `--yes` gives both
18
+ * confirmations without a prompt.
19
+ * - No PR ever reaches `completed`: the factory never merges, and exercise
20
+ * and heal-drill assert it with `az repos pr list --status completed`.
12
21
  * - Later phases use `--run <runId>`, or the newest manifest.
13
22
  * - The manifest `~/.omg/acceptance/<runId>.json` records every created id
14
23
  * and is written before each create. The clone, the progress file, the OMC
15
- * recording (`OMG_ADO_RECORD_DIR`) and the capture live in
24
+ * recording (`OMG_ADO_RECORD_DIR`: `recorded/`, and `recorded-enqueue/` for
25
+ * the enqueue phase) and the capture live in
16
26
  * `~/.omg/acceptance/<runId>/`.
17
27
  * - `--dry-run` prints the exact argv of every command and every file it
18
28
  * would write, and runs and writes nothing (not even read-only commands).
@@ -33,18 +43,21 @@
33
43
  */
34
44
 
35
45
  import { spawnSync } from 'node:child_process';
36
- import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
46
+ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
37
47
  import { homedir } from 'node:os';
48
+ import { isatty } from 'node:tty';
38
49
  import { dirname, join, resolve } from 'node:path';
39
50
  import { fileURLToPath, pathToFileURL } from 'node:url';
40
- import { backlogToWorkItems } from './lib/backlog-to-workitems.mjs';
51
+ import { backlogToTicketFile, inlineHtml } from './lib/backlog-to-workitems.mjs';
41
52
 
42
53
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
43
54
  export const RUN_PREFIX = 'omg-acc-';
44
55
  const RUN_ID = /^omg-acc-\d{12}$/;
45
56
  const GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
46
- export const PHASES = ['preflight', 'create', 'exercise', 'heal-drill', 'capture', 'cleanup'];
47
- export const ALL_PHASES = ['preflight', 'create', 'exercise', 'capture'];
57
+ export const PHASES = ['preflight', 'create', 'enqueue', 'exercise', 'heal-drill', 'capture', 'cleanup'];
58
+ export const ALL_PHASES = ['preflight', 'create', 'enqueue', 'exercise', 'capture'];
59
+ /** The spec work item's type: a Feature is never in the intake (check buckets it needs-split). */
60
+ export const SPEC_TYPE = 'Feature';
48
61
  export const DEFAULT_POOL = 'Default';
49
62
  /** The heal drill's failing test, removed again by a revert commit. */
50
63
  export const DRILL_TEST = 'src/omg-acceptance-drill.test.ts';
@@ -66,7 +79,7 @@ export function orgNameOf(orgUrl) {
66
79
  }
67
80
 
68
81
  export function parseAcceptanceArgs(argv, home = join(homedir(), '.omg', 'acceptance')) {
69
- const o = { phase: 'all', withLanes: false, dryRun: false, home, pool: { kind: 'self-hosted', name: DEFAULT_POOL } };
82
+ const o = { phase: 'all', withLanes: false, dryRun: false, yes: false, home, pool: { kind: 'self-hosted', name: DEFAULT_POOL } };
70
83
  let poolName, hosted = false;
71
84
  for (let i = 0; i < argv.length; i++) {
72
85
  const flag = argv[i];
@@ -84,6 +97,7 @@ export function parseAcceptanceArgs(argv, home = join(homedir(), '.omg', 'accept
84
97
  else if (flag === '--project-id') o.projectId = value();
85
98
  else if (flag === '--home') o.home = resolve(value());
86
99
  else if (flag === '--dry-run') o.dryRun = true;
100
+ else if (flag === '--yes') o.yes = true;
87
101
  else throw new Error(`unknown flag ${flag}`);
88
102
  }
89
103
  if (o.phase !== 'all' && !PHASES.includes(o.phase)) throw new Error(`--phase must be one of ${[...PHASES, 'all'].join(', ')}`);
@@ -164,13 +178,6 @@ export function assertCleanupAllowed(manifest, { requestedId, shown } = {}) {
164
178
  return id;
165
179
  }
166
180
 
167
- /** The predecessor link type's name from `az boards work-item relation list-type`. */
168
- export function predecessorRelation(types) {
169
- const found = (Array.isArray(types) ? types : []).find((t) => typeof t?.name === 'string' && t.name.toLowerCase() === 'predecessor');
170
- if (!found) throw new Error('the org has no "Predecessor" work item relation type (az boards work-item relation list-type)');
171
- return found.name.toLowerCase();
172
- }
173
-
174
181
  /** Deep search: the first value of `key` on an object that passes `pick`. */
175
182
  function findDeep(value, pick) {
176
183
  if (Array.isArray(value)) {
@@ -189,13 +196,19 @@ function findDeep(value, pick) {
189
196
  return undefined;
190
197
  }
191
198
 
192
- export const firstRunnable = (checkJson) => findDeep(checkJson, (o) => (o.bucket === 'runnable' && o.id !== undefined ? String(o.id) : undefined));
193
199
  export const firstSig8 = (scanJson) => findDeep(scanJson, (o) => (typeof o.sig8 === 'string' && /^[0-9a-f]{8}$/.test(o.sig8) ? o.sig8 : undefined));
194
200
 
195
- /** The design's `exercise` assertions over the OMC recording and the run's output. */
201
+ /**
202
+ * The design's `exercise` assertions over the OMC recording and the run's output.
203
+ * record.ts keeps one file per route + parameters key, so a repeated call
204
+ * leaves only its last answer: the PR status and PR PATCH checks see the last
205
+ * call of each key and are best-effort. noCompletedPr (az repos pr list) is
206
+ * the authoritative never-merged check.
207
+ */
196
208
  export function exerciseAssertions(recorded, runOutput, itemId) {
197
209
  const ok = (f) => f.exitCode === undefined || f.exitCode === 0;
198
210
  const of = (route) => recorded.filter((f) => f.route === route && ok(f));
211
+ const setsState = (f) => Array.isArray(f.requestBody) && f.requestBody.some((op) => op?.path === '/fields/System.State');
199
212
  const prStatuses = of('git.pullRequests.GET').flatMap((f) => (Array.isArray(f.stdout?.value) ? f.stdout.value : [f.stdout])).map((p) => p?.status).filter(Boolean);
200
213
  return [
201
214
  { what: 'a draft PR exists, linked to the work item', ok: of('git.pullRequests.POST').some((f) => f.requestBody?.isDraft === true && (f.requestBody?.workItemRefs ?? []).some((r) => String(r.id) === String(itemId))) },
@@ -203,10 +216,80 @@ export function exerciseAssertions(recorded, runOutput, itemId) {
203
216
  { what: 'the run parks at awaiting-human: merge', ok: /awaiting-human:?\s*merge/i.test(runOutput) },
204
217
  { what: 'the PR is still active and never completed', ok: prStatuses.length > 0 && prStatuses.every((s) => s !== 'completed') },
205
218
  { what: 'no PR PATCH other than {isDraft:false}', ok: recorded.filter((f) => f.route === 'git.pullRequests.PATCH').every((f) => JSON.stringify(f.requestBody) === '{"isDraft":false}') },
206
- { what: 'progress moved the work item', ok: of('wit.workItems.PATCH').length > 0 },
219
+ { what: `progress moved #${itemId} (a System.State PATCH)`, ok: of('wit.workItems.PATCH').some((f) => String(f.routeParameters?.id) === String(itemId) && setsState(f)) },
220
+ ];
221
+ }
222
+
223
+ /**
224
+ * `enqueue`'s assertions: the dry run plans every ticket of the file, the
225
+ * real run gives each one an id and marks the runnable ones, and a second
226
+ * dry run finds every ticket unchanged (idempotent by shipyard-key).
227
+ */
228
+ export function enqueueAssertions(file, dry, real, again) {
229
+ const keys = file.tickets.map((t) => t.key);
230
+ const rows = (json) => new Map((Array.isArray(json?.items) ? json.items : []).map((r) => [r.key, r]));
231
+ const planned = rows(dry);
232
+ const done = rows(real);
233
+ const rerun = rows(again);
234
+ return [
235
+ { what: `enqueue --dry-run plans all ${keys.length} tickets`, ok: dry?.ok === true && dry?.dryRun === true && keys.every((k) => planned.has(k)) },
236
+ { what: 'enqueue gives every ticket a work item id', ok: real?.ok === true && keys.every((k) => Number.isInteger(done.get(k)?.id) && ['created', 'updated', 'unchanged'].includes(done.get(k)?.action)) },
237
+ { what: 'the mark step marked the runnable tickets', ok: Array.isArray(real?.mark?.marked) && real.mark.marked.length + (real.mark.alreadyMarked?.length ?? 0) > 0 && (real.mark.failed?.length ?? 0) === 0 },
238
+ { what: 'an enqueue re-run (--dry-run) finds every ticket unchanged', ok: keys.every((k) => rerun.get(k)?.action === 'unchanged') },
207
239
  ];
208
240
  }
209
241
 
242
+ /**
243
+ * `omg factory check --parent <spec>` against the enqueued tickets
244
+ * (`{ key: { id, blockedBy: [keys] } }`): every ticket is a child of the spec,
245
+ * a ticket with an open predecessor is blocked by exactly that one
246
+ * (`depends-on:#n,...`), and `picked` (run --next) was runnable.
247
+ */
248
+ export function orderingAssertions(checkJson, tickets, picked) {
249
+ const rows = new Map((Array.isArray(checkJson?.items) ? checkJson.items : []).map((r) => [String(r.id), r]));
250
+ const all = Object.values(tickets);
251
+ const waiting = all.filter((t) => t.blockedBy.length > 0);
252
+ const blockedBy = (t) => {
253
+ const r = rows.get(String(t.id));
254
+ const named = r?.bucket === 'blocked' && typeof r.reasons?.[0] === 'string' && r.reasons[0].startsWith('depends-on:') ? r.reasons[0].slice('depends-on:'.length).split(',') : [];
255
+ return t.blockedBy.every((k) => tickets[k] && named.includes(`#${tickets[k].id}`));
256
+ };
257
+ const results = [
258
+ { what: `check --parent lists all ${all.length} tickets`, ok: all.length > 0 && all.every((t) => rows.has(String(t.id))) },
259
+ { what: `the ${waiting.length} ticket(s) with a predecessor are blocked by it (depends-on)`, ok: waiting.every(blockedBy) },
260
+ ];
261
+ if (picked !== undefined) {
262
+ const r = rows.get(String(picked));
263
+ results.push({ what: `run --next picked #${picked}, a runnable ticket without an open predecessor`, ok: r?.bucket === 'runnable' && !waiting.some((t) => String(t.id) === String(picked)) });
264
+ }
265
+ return results;
266
+ }
267
+
268
+ /**
269
+ * The tracker write-back of a run parked at the human merge (integration
270
+ * design §3.6): the item's merge gate comment, the spec's rollup line for
271
+ * the item, and no edit of the spec work item.
272
+ */
273
+ export function outcomeAssertions(recorded, specId, itemId) {
274
+ const ok = (f) => f.exitCode === undefined || f.exitCode === 0;
275
+ const comments = (id) => recorded.filter((f) => f.route === 'wit.comments.POST' && ok(f) && String(f.routeParameters?.workItemId) === String(id)).map((f) => String(f.requestBody?.text ?? ''));
276
+ return [
277
+ { what: `#${itemId} got the merge gate comment`, ok: comments(itemId).some((t) => t.includes('awaiting a human: **merge**')) },
278
+ { what: `the spec #${specId} got the rollup line "- #${itemId} ready to merge"`, ok: comments(specId).some((t) => t.includes(`- #${itemId} ready to merge:`)) },
279
+ { what: `the spec #${specId} itself is never edited`, ok: !recorded.some((f) => f.route === 'wit.workItems.PATCH' && String(f.routeParameters?.id) === String(specId)) },
280
+ ];
281
+ }
282
+
283
+ /**
284
+ * The factory never merges: no PR of the run's repository is `completed`.
285
+ * https://learn.microsoft.com/en-us/cli/azure/repos/pr?view=azure-cli-latest#az-repos-pr-list
286
+ */
287
+ function noCompletedPr(ctx, m) {
288
+ const res = ctx.az(['repos', 'pr', 'list', '--status', 'completed', '--repository', m.repo.name, '--project', m.project.name, '--org', orgOf(m)], { placeholder: [] });
289
+ const completed = Array.isArray(res.json) ? res.json.map((p) => p?.pullRequestId) : undefined;
290
+ return { what: `no PR of the run reached completed (the factory never merges)${completed?.length ? `; completed: ${completed.join(', ')}` : ''}`, ok: Array.isArray(completed) && completed.length === 0 };
291
+ }
292
+
210
293
  const parseMaybe = (text) => {
211
294
  try {
212
295
  return JSON.parse(text);
@@ -239,12 +322,21 @@ export function azArgv(args) {
239
322
  /**
240
323
  * The side-effect boundary: every spawn and file write goes through here,
241
324
  * and in dry-run mode each one is printed, never done. `deps`: spawn
242
- * (spawnSync's shape), azEntry, log, now, sleep(ms), redact, env, runLimits.
325
+ * (spawnSync's shape), azEntry, log, now, sleep(ms), redact, env, runLimits,
326
+ * confirm(question) → boolean (`--yes` answers yes; a dry run never asks),
327
+ * userConfig `{ path, trustedAuthors() }` (the user config at its default
328
+ * location, read only).
243
329
  */
244
330
  export function createContext(o, deps) {
245
331
  const log = deps.log ?? console.log;
246
332
  const redact = deps.redact ?? ((s) => s);
247
- const ctx = { o, log, manifest: undefined, now: deps.now ?? (() => new Date()), sleep: deps.sleep ?? (() => {}), env: deps.env ?? process.env, runLimits: deps.runLimits };
333
+ const userConfig = deps.userConfig ?? { path: '<user config>', trustedAuthors: () => [] };
334
+ const ctx = { o, log, manifest: undefined, now: deps.now ?? (() => new Date()), sleep: deps.sleep ?? (() => {}), env: deps.env ?? process.env, runLimits: deps.runLimits, userConfig };
335
+ ctx.confirm = (question) => {
336
+ if (o.dryRun) return (log(`[dry-run] would ask: ${question}`), true);
337
+ if (o.yes) return (log(`${question} yes (--yes)`), true);
338
+ return Boolean(deps.confirm?.(question));
339
+ };
248
340
  ctx.exec = (label, cmd, args, { cwd, env, placeholder, allowFail = false } = {}) => {
249
341
  const shown = `${label}: ${JSON.stringify([cmd, ...args])}${cwd ? ` (cwd ${cwd})` : ''}${env && Object.keys(env).length ? ` (env ${Object.keys(env).map((k) => `${k}=${env[k]}`).join(' ')})` : ''}`;
250
342
  if (o.dryRun) {
@@ -292,13 +384,30 @@ function requireManifest(ctx) {
292
384
  ctx.manifest = {
293
385
  runId: placeholderId, org: o.org ?? 'https://dev.azure.com/<org>', source: o.source ?? '<source>', runDir: join(o.home, placeholderId), pool: o.pool,
294
386
  project: { name: placeholderId, id: '00000000-0000-0000-0000-000000000000' }, repo: { name: placeholderId, id: '<repoId>', url: '<repoUrl>' },
295
- pipeline: { id: '<definitionId>' }, policy: { id: '<policyId>' }, workItems: {}, trustedAuthorsAdded: [],
387
+ pipeline: { id: '<definitionId>' }, policy: { id: '<policyId>' }, spec: { id: '<specId>', createdBy: '<spec creator uniqueName>' }, tickets: {}, trustedAuthorsAdded: [],
296
388
  };
297
389
  return ctx.manifest;
298
390
  }
299
391
 
300
392
  const orgOf = (m) => m.org;
301
393
  const repoDirOf = (m) => join(m.runDir, 'repo');
394
+ /**
395
+ * enqueue's own recording: its relation and mark PATCHes must not reach
396
+ * `recorded/`, where exercise looks for the progress PATCH.
397
+ */
398
+ const enqueueRecordEnv = (m) => ({ OMG_ADO_RECORD_DIR: join(m.runDir, 'recorded-enqueue') });
399
+
400
+ /** `omg factory setup` for the run's repository; `extra` goes before the confirmation flags. */
401
+ const setupArgs = (m, extra = []) => [
402
+ 'factory', 'setup', '--forge', 'azure-devops', '--org', m.org.replace(/^https:\/\/dev\.azure\.com\//, ''), '--project', m.project.name, '--repo', m.repo.name,
403
+ '--intake', `area-tag:${m.project.name}#factory`, '--progress', join(m.runDir, 'progress.json'), ...extra, '--yes', '--json',
404
+ ];
405
+
406
+ /** The spec work item of a run made before the enqueue flow is missing: such a run cannot take the later phases. */
407
+ function requireSpec(m) {
408
+ if (m.spec?.id === undefined || m.spec?.id === null) throw new Error(`run ${m.runId} has no spec work item (it predates the enqueue flow); start a new run with --phase create`);
409
+ return m.spec;
410
+ }
302
411
 
303
412
  export function preflight(ctx) {
304
413
  const { o } = ctx;
@@ -318,6 +427,7 @@ export function preflight(ctx) {
318
427
  ctx.log(poolAdvice(o.pool, o.dryRun ? undefined : pools.json));
319
428
  if (o.withLanes) ctx.log('Copilot: --with-lanes runs one factory run (implement + review, maybe fix/ci-fix lanes) and, in heal-drill, one heal debugger lane and then the approved ci-heal run (implement + review lanes); check your Copilot premium-request quota first.');
320
429
  else ctx.log('Copilot: no lane runs without --with-lanes (0 credits).');
430
+ ctx.log('User config: enqueue adds the spec creator to factory.forge.azureDevOps.trustedAuthors after it prints the change and you confirm (or --yes); cleanup lists it and never removes it.');
321
431
  if (!existsSync(join(ROOT, 'dist', 'forge', 'ado', 'az-binary.js'))) problems.push('no OMC build: run npm run build first');
322
432
  if (problems.length && o.dryRun) ctx.log(`[dry-run] preflight would fail:\n- ${problems.join('\n- ')}`);
323
433
  else if (problems.length) throw new Error(`preflight failed:\n- ${problems.join('\n- ')}`);
@@ -331,7 +441,7 @@ export function create(ctx) {
331
441
  const repoDir = join(runDir, 'repo');
332
442
  const m = (ctx.manifest = {
333
443
  schemaVersion: 1, runId, org: o.org, source: o.source, runDir, pool: o.pool, createdAt: ctx.now().toISOString(),
334
- project: { name: runId }, repo: { name: runId }, pipeline: null, policy: null, workItems: {}, pending: null, trustedAuthorsAdded: [],
444
+ project: { name: runId }, repo: { name: runId }, pipeline: null, policy: null, spec: null, tickets: {}, pending: null, trustedAuthorsAdded: [],
335
445
  });
336
446
  const pending = (what) => {
337
447
  m.pending = what;
@@ -368,27 +478,19 @@ export function create(ctx) {
368
478
  m.pipeline = { id: pipeline.json?.id };
369
479
  pending(null);
370
480
 
371
- const relation = predecessorRelation(ctx.az(['boards', 'work-item', 'relation', 'list-type', ...org], { placeholder: [{ name: 'Predecessor' }] }).json);
372
- // A dry run has no clone; it reads the same file from the source (read-only).
373
- const { items, unknown } = backlogToWorkItems(ctx.read(join(o.dryRun ? o.source : repoDir, 'BACKLOG.md')));
374
- for (const u of unknown) ctx.log(`note: ${u}`);
375
- for (const item of items) {
376
- pending(`work item ${item.key}`);
377
- const created = ctx.az([
378
- 'boards', 'work-item', 'create', '--type', 'User Story', '--title', item.title, '--description', item.descriptionHtml,
379
- '--fields', `Microsoft.VSTS.Common.AcceptanceCriteria=${item.acceptanceHtml}`, 'System.Tags=factory', ...scope,
380
- ], { placeholder: { id: `<wi:${item.key}>` } });
381
- m.workItems[item.key] = created.json?.id;
382
- pending(null);
383
- }
384
- for (const item of items) {
385
- const targets = item.dependsOn.map((k) => m.workItems[k]).filter((id) => id !== undefined);
386
- if (targets.length) ctx.az(['boards', 'work-item', 'relation', 'add', '--id', String(m.workItems[item.key]), '--relation-type', relation, '--target-id', targets.join(','), ...org]);
387
- }
481
+ // The spec (launch Phase 2): the parent the enqueued tickets link to. No factory tag, so it is not intake.
482
+ pending('spec');
483
+ const spec = ctx.az([
484
+ 'boards', 'work-item', 'create', '--type', SPEC_TYPE, '--title', `${runId} spec: the BACKLOG.md tickets`,
485
+ '--description', `<p>${inlineHtml('omg live acceptance spec: the `BACKLOG.md` tickets of the test repository, enqueued as its children with `omg factory enqueue`.')}</p>`, ...scope,
486
+ ], { placeholder: { id: '<specId>', fields: { 'System.CreatedBy': { uniqueName: '<spec creator uniqueName>' } } } });
487
+ const createdBy = spec.json?.fields?.['System.CreatedBy'];
488
+ m.spec = { id: spec.json?.id, createdBy: typeof createdBy === 'string' ? createdBy : createdBy?.uniqueName };
489
+ if (m.spec.id === undefined) throw new Error('created the spec work item but could not read its id');
490
+ pending(null);
388
491
 
389
- const progress = join(runDir, 'progress.json');
390
- ctx.write(progress, `${JSON.stringify(AGILE_PROGRESS, null, 2)}\n`);
391
- ctx.omg(['factory', 'setup', '--forge', 'azure-devops', '--org', o.orgName, '--project', runId, '--repo', runId, '--intake', `area-tag:${runId}#factory`, '--progress', progress, '--yes', '--json'], { cwd: repoDir });
492
+ ctx.write(join(runDir, 'progress.json'), `${JSON.stringify(AGILE_PROGRESS, null, 2)}\n`);
493
+ ctx.omg(setupArgs(m), { cwd: repoDir });
392
494
  git('add', '.copilot/omg.jsonc');
393
495
  git('commit', '-m', 'chore: omg factory config for the live acceptance run');
394
496
  git('push', 'origin', 'main');
@@ -405,8 +507,89 @@ export function create(ctx) {
405
507
  pending(null);
406
508
  m.createdDone = true;
407
509
  ctx.saveManifest();
408
- ctx.log(`created ${runId}: project ${m.project.id}, ${items.length} work items, pipeline ${m.pipeline.id}`);
409
- ctx.log(`trustedAuthors: none added. To accept your omg-plan: comments, add your uniqueName to factory.forge.azureDevOps.trustedAuthors in the user config yourself (omg factory setup --trusted-author <you> --scope user).`);
510
+ ctx.log(`created ${runId}: project ${m.project.id}, spec work item ${m.spec.id} (created by ${m.spec.createdBy ?? 'unknown'}), pipeline ${m.pipeline.id}`);
511
+ ctx.log('trustedAuthors: none added yet; the enqueue phase asks before it adds the spec creator to the user config.');
512
+ }
513
+
514
+ /**
515
+ * Trust the spec's creator: on Azure DevOps enqueue (and check) trust only
516
+ * the uniqueNames in the user config's factory.forge.azureDevOps.trustedAuthors.
517
+ * The write is printed and confirmed first. The manifest records the name as
518
+ * `trustPending` before the write and moves it to `trustedAuthorsAdded` once
519
+ * setup succeeds, so cleanup can list it either way.
520
+ */
521
+ function trustSpecCreator(ctx, m) {
522
+ const author = requireSpec(m).createdBy;
523
+ if (typeof author !== 'string' || !author) throw new Error(`the manifest records no creator of spec #${m.spec.id}`);
524
+ const path = ctx.userConfig.path;
525
+ const current = ctx.userConfig.trustedAuthors();
526
+ if (current.some((a) => a.toLowerCase() === author.toLowerCase())) return ctx.log(`ok ${author} is already in factory.forge.azureDevOps.trustedAuthors (${path})`);
527
+ const next = [...current, author];
528
+ ctx.log([
529
+ `user-scope write: ${path}`,
530
+ ` factory.forge.azureDevOps.trustedAuthors: ${JSON.stringify(current)} -> ${JSON.stringify(next)}`,
531
+ ` ${author} created spec #${m.spec.id}; enqueue trusts only these uniqueNames. Cleanup lists what this run added; it never removes it.`,
532
+ ].join('\n'));
533
+ if (!ctx.confirm(`Add ${author} to factory.forge.azureDevOps.trustedAuthors in ${path}?`)) {
534
+ throw new Error(`not confirmed: ${path} is unchanged. Add ${author} there yourself, or rerun with --yes`);
535
+ }
536
+ // Pending until setup succeeds: a failed setup may or may not have written the user config.
537
+ m.trustPending = author;
538
+ ctx.saveManifest();
539
+ ctx.omg(setupArgs(m, ['--trusted-author', next.join(','), '--scope', 'user']), { cwd: repoDirOf(m), env: enqueueRecordEnv(m) });
540
+ m.trustedAuthorsAdded = [...new Set([...(m.trustedAuthorsAdded ?? []), author])];
541
+ m.trustPending = null;
542
+ ctx.saveManifest();
543
+ }
544
+
545
+ /** One `omg factory enqueue` call; a refusal (exit 2) or failure throws with enqueue's own error. */
546
+ function enqueueCall(ctx, m, file, extra, placeholder) {
547
+ const res = ctx.omg(['factory', 'enqueue', '--spec', String(m.spec.id), '--file', file, ...extra, '--json'], { cwd: repoDirOf(m), allowFail: true, placeholder, env: enqueueRecordEnv(m) });
548
+ if (res.status !== 0) {
549
+ // A failed real enqueue exits 1 with { ok: false, warnings } and no error field.
550
+ const ids = (Array.isArray(res.json?.items) ? res.json.items : []).filter((r) => Number.isInteger(r?.id));
551
+ if (ids.length && !extra.includes('--dry-run')) {
552
+ m.enqueuedBeforeFailure = Object.fromEntries(ids.map((r) => [r.key, r.id]));
553
+ ctx.saveManifest();
554
+ }
555
+ const cause = res.json?.error ?? (Array.isArray(res.json?.warnings) && res.json.warnings.length ? res.json.warnings.join('; ') : res.stderr.trim().slice(0, 2000));
556
+ const rerun = extra.includes('--dry-run') ? '' : `${ids.length ? `; the manifest records ids ${ids.map((r) => `#${r.id}`).join(', ')}` : ''}; rerunning --phase enqueue is idempotent (enqueue matches tickets by shipyard-key)`;
557
+ throw new Error(`omg factory enqueue${extra.map((a) => ` ${a}`).join('')} exited ${res.status}: ${cause}${rerun}`);
558
+ }
559
+ return res.json;
560
+ }
561
+
562
+ /**
563
+ * launch's hand-off (integration design §3.2): the BACKLOG.md tickets as a
564
+ * ticket file of the spec, `enqueue --dry-run`, the signature (the dry run
565
+ * is shown, then confirmed), the real enqueue, and a second dry run that
566
+ * must find every ticket unchanged.
567
+ */
568
+ export function enqueue(ctx) {
569
+ const { o } = ctx;
570
+ const m = requireManifest(ctx);
571
+ requireSpec(m);
572
+ trustSpecCreator(ctx, m);
573
+ // A dry run has no clone; it reads the same file from the source (read-only).
574
+ const backlog = join(o.dryRun ? o.source ?? m.source : repoDirOf(m), 'BACKLOG.md');
575
+ if (o.dryRun && !existsSync(backlog)) ctx.log(`[dry-run] no ${backlog}: pass --source to preview the ticket file (the real run reads the clone's BACKLOG.md)`);
576
+ const { file, unknown } = o.dryRun && !existsSync(backlog) ? { file: { schemaVersion: 1, spec: m.spec.id, tickets: [] }, unknown: [] } : backlogToTicketFile(ctx.read(backlog), Number(m.spec.id));
577
+ for (const u of unknown) ctx.log(`note: ${u}`);
578
+ const ticketFile = join(m.runDir, 'tickets.json');
579
+ ctx.write(ticketFile, `${JSON.stringify(file, null, 2)}\n`);
580
+
581
+ const dry = enqueueCall(ctx, m, ticketFile, ['--dry-run'], { ok: true, dryRun: true, items: [] });
582
+ if (!o.dryRun) for (const r of dry?.items ?? []) ctx.log(`plan ${r.key} ${r.id === null ? '(new)' : `#${r.id}`} ${r.action}${r.planned?.links?.length ? ` links ${r.planned.links.join(', ')}` : ''}`);
583
+ if (!ctx.confirm(`Signature (launch C3): enqueue these ${file.tickets.length} tickets as children of spec #${m.spec.id}?`)) throw new Error('enqueue not signed: nothing written');
584
+ m.pending = 'enqueue';
585
+ ctx.saveManifest();
586
+ const real = enqueueCall(ctx, m, ticketFile, [], { ok: true, dryRun: false, items: [], mark: { marked: [] } });
587
+ const byKey = new Map(file.tickets.map((t) => [t.key, t]));
588
+ m.tickets = Object.fromEntries((real?.items ?? []).filter((r) => byKey.has(r.key)).map((r) => [r.key, { id: r.id, blockedBy: byKey.get(r.key).blockedBy }]));
589
+ m.pending = null;
590
+ ctx.saveManifest();
591
+ const again = enqueueCall(ctx, m, ticketFile, ['--dry-run'], { ok: true, dryRun: true, items: [] });
592
+ return report(ctx, 'enqueue', enqueueAssertions(file, dry, real, again));
410
593
  }
411
594
 
412
595
  export function exercise(ctx) {
@@ -415,24 +598,39 @@ export function exercise(ctx) {
415
598
  const cwd = repoDirOf(m);
416
599
  const results = [];
417
600
  const step = (what, res) => results.push({ what, ok: res.status === 0 });
418
- const check = ctx.omg(['factory', 'check', '--json'], { cwd, allowFail: true, placeholder: { items: [{ id: '<first runnable id>', bucket: 'runnable' }] } });
419
- step('omg factory check --json', check);
601
+ const spec = String(requireSpec(m).id);
602
+ const tickets = m.tickets ?? {};
603
+ if (!o.dryRun && Object.keys(tickets).length === 0) throw new Error(`run ${m.runId} has no enqueued tickets; run --phase enqueue first`);
604
+ step('omg factory check --json', ctx.omg(['factory', 'check', '--json'], { cwd, allowFail: true, placeholder: { items: [] } }));
605
+ const checkParent = () => ctx.omg(['factory', 'check', '--parent', spec, '--json'], { cwd, allowFail: true, placeholder: { items: [] } });
606
+ const before = checkParent();
607
+ step(`omg factory check --parent ${spec} --json`, before);
420
608
  step('omg factory board --json', ctx.omg(['factory', 'board', '--json'], { cwd, allowFail: true, placeholder: {} }));
421
- const first = firstRunnable(check.json);
422
- if (!first) results.push({ what: 'a runnable work item', ok: false });
423
- else {
424
- step(`omg factory run ${first} --dry-run`, ctx.omg(['factory', 'run', first, '--dry-run'], { cwd, allowFail: true }));
425
- if (o.withLanes) {
426
- const loaded = o.dryRun || !ctx.runLimits ? undefined : ctx.runLimits(cwd);
427
- ctx.log(`Copilot spend for this run is capped by factory.run: ${loaded ? JSON.stringify(loaded.limits) : '(the limits omg factory run resolves)'}`);
428
- const run = ctx.omg(['factory', 'run', first], { cwd, allowFail: true });
429
- step(`omg factory run ${first}`, run);
430
- step('omg factory poll --once --json', ctx.omg(['factory', 'poll', '--once', '--json'], { cwd, allowFail: true, placeholder: {} }));
431
- const recordedDir = join(m.runDir, 'recorded');
432
- const recorded = o.dryRun || !existsSync(recordedDir) ? [] : readdirSync(recordedDir).filter((n) => n.endsWith('.json')).map((n) => JSON.parse(readFileSync(join(recordedDir, n), 'utf8')));
433
- if (!o.dryRun) results.push(...exerciseAssertions(recorded, `${run.stdout}\n${run.stderr}`, first));
434
- } else ctx.log('no lanes: pass --with-lanes to run the factory for real (spends Copilot credits)');
435
- }
609
+ const next = ['factory', 'run', '--next', '--parent', spec];
610
+ const dry = ctx.omg([...next, '--dry-run', '--json'], { cwd, allowFail: true, placeholder: { next: '<next runnable id>' } });
611
+ step(`omg factory run --next --parent ${spec} --dry-run`, dry);
612
+ const picked = dry.json?.next ?? undefined;
613
+ if (!o.dryRun) results.push(...orderingAssertions(before.json, tickets, picked ?? null));
614
+ if (o.withLanes) {
615
+ const loaded = o.dryRun || !ctx.runLimits ? undefined : ctx.runLimits(cwd);
616
+ ctx.log(`Copilot spend for this run is capped by factory.run: ${loaded ? JSON.stringify(loaded.limits) : '(the limits omg factory run resolves)'}`);
617
+ const run = ctx.omg([...next, '--json'], { cwd, allowFail: true });
618
+ step(`omg factory run --next --parent ${spec}`, run);
619
+ const ran = run.json?.next;
620
+ step('omg factory poll --once --json', ctx.omg(['factory', 'poll', '--once', '--json'], { cwd, allowFail: true, placeholder: {} }));
621
+ const after = checkParent();
622
+ step(`omg factory check --parent ${spec} --json (after the run)`, after);
623
+ const recordedDir = join(m.runDir, 'recorded');
624
+ const recorded = o.dryRun || !existsSync(recordedDir) ? [] : readdirSync(recordedDir).filter((n) => n.endsWith('.json')).map((n) => JSON.parse(readFileSync(join(recordedDir, n), 'utf8')));
625
+ if (!o.dryRun) {
626
+ results.push({ what: `the real run took the dry run's pick #${picked}`, ok: ran !== undefined && String(ran) === String(picked) });
627
+ results.push(...exerciseAssertions(recorded, `${run.stdout}\n${run.stderr}`, ran), ...outcomeAssertions(recorded, spec, ran));
628
+ const row = (Array.isArray(after.json?.items) ? after.json.items : []).find((r) => String(r.id) === String(ran));
629
+ results.push({ what: `#${ran} is no longer runnable while its PR waits for the human merge`, ok: row?.bucket === 'blocked' });
630
+ results.push(...orderingAssertions(after.json, tickets));
631
+ }
632
+ } else ctx.log('no lanes: pass --with-lanes to run the factory for real (spends Copilot credits)');
633
+ results.push(noCompletedPr(ctx, m));
436
634
  return report(ctx, 'exercise', results);
437
635
  }
438
636
 
@@ -499,6 +697,7 @@ export function healDrill(ctx) {
499
697
  if (run.status === 0) step(`omg factory heal approve ${sig8}`, ctx.omg(['factory', 'heal', 'approve', sig8], { cwd, allowFail: true }));
500
698
  }
501
699
  }
700
+ results.push(noCompletedPr(ctx, m));
502
701
  } finally {
503
702
  git('revert', '--no-edit', sha);
504
703
  pushWithPolicyOff();
@@ -508,7 +707,8 @@ export function healDrill(ctx) {
508
707
 
509
708
  export function captureFixtures(ctx) {
510
709
  const m = requireManifest(ctx);
511
- const ids = Object.values(m.workItems ?? {}).filter((id) => /^\d+$/.test(String(id)));
710
+ // The spec and its enqueued tickets (`workItems`: runs made before the enqueue flow).
711
+ const ids = [m.spec?.id, ...Object.values(m.tickets ?? {}).map((t) => t.id), ...Object.values(m.workItems ?? {})].filter((id) => /^\d+$/.test(String(id)));
512
712
  ctx.node('ado-capture.mjs', [
513
713
  '--org', orgOf(m), '--project', m.project.name, '--repo', m.repo.name, '--moment', `acceptance-${runIdAt(ctx.now()).slice(RUN_PREFIX.length)}`,
514
714
  '--out', join(m.runDir, 'capture'), ...(ids.length ? ['--work-items', ids.join(',')] : []),
@@ -551,10 +751,13 @@ export function cleanup(ctx) {
551
751
  ctx.saveManifest();
552
752
  if (removeRepo) ctx.rm(repoDir);
553
753
  ctx.log(`deleted project ${m.project.name} (${id}); it is restorable for 28 days (Organization settings > Projects).`);
554
- ctx.log(m.trustedAuthorsAdded?.length ? `remove these trustedAuthors from your user config: ${m.trustedAuthorsAdded.join(', ')}` : 'no trustedAuthors were added by this run.');
754
+ ctx.log(m.trustedAuthorsAdded?.length
755
+ ? `this run added ${m.trustedAuthorsAdded.join(', ')} to factory.forge.azureDevOps.trustedAuthors in ${ctx.userConfig.path}; cleanup never edits the user config, so remove them there yourself if they should not stay trusted.`
756
+ : 'no trustedAuthors were added by this run.');
757
+ if (m.trustPending) ctx.log(`${m.trustPending} may have been added to factory.forge.azureDevOps.trustedAuthors in ${ctx.userConfig.path}: the setup that adds it did not finish; check there yourself.`);
555
758
  }
556
759
 
557
- const PHASE_FNS = { preflight, create, exercise, 'heal-drill': healDrill, capture: captureFixtures, cleanup };
760
+ const PHASE_FNS = { preflight, create, enqueue, exercise, 'heal-drill': healDrill, capture: captureFixtures, cleanup };
558
761
 
559
762
  export function runPhases(ctx) {
560
763
  for (const phase of ctx.o.phase === 'all' ? ALL_PHASES : [ctx.o.phase]) {
@@ -564,17 +767,45 @@ export function runPhases(ctx) {
564
767
  if (ctx.o.phase === 'all' && ctx.manifest) ctx.log(`\nnext: --phase heal-drill --run ${ctx.manifest.runId} (needs an agent), then --phase cleanup --org ${ctx.manifest.org} --run ${ctx.manifest.runId}`);
565
768
  }
566
769
 
770
+ /**
771
+ * A y/N question on the terminal; no terminal or a read error is a no, with
772
+ * the reason printed. isatty(0), never process.stdin.isTTY: touching
773
+ * process.stdin makes fd 0 non-blocking on Linux and macOS, and readSync(0)
774
+ * then throws EAGAIN. `io` is for tests.
775
+ */
776
+ export function confirmOnTty(question, io = {}) {
777
+ const { isTerminal = () => isatty(0), read = (buf) => readSync(0, buf, 0, buf.length, null), out = (s) => process.stdout.write(s) } = io;
778
+ if (!isTerminal()) {
779
+ out(`${question} no: stdin is not a terminal (pass --yes to confirm)\n`);
780
+ return false;
781
+ }
782
+ out(`${question} [y/N] `);
783
+ const buf = Buffer.alloc(256);
784
+ let answer = '';
785
+ try {
786
+ while (!answer.includes('\n')) {
787
+ const n = read(buf);
788
+ if (n === 0) break;
789
+ answer += buf.toString('utf8', 0, n);
790
+ }
791
+ } catch (error) {
792
+ out(`no: could not read the answer (${error?.code ?? error?.message ?? error}); pass --yes to confirm\n`);
793
+ return false;
794
+ }
795
+ return /^\s*y(es)?\s*$/i.test(answer);
796
+ }
797
+
567
798
  async function main() {
568
799
  let o;
569
800
  try {
570
801
  o = parseAcceptanceArgs(process.argv.slice(2));
571
802
  } catch (error) {
572
803
  console.error(`ado-acceptance: ${error.message}`);
573
- console.error('usage: node scripts/ado-acceptance.mjs --org https://dev.azure.com/<org> --source <clone> [--phase preflight|create|exercise|heal-drill|capture|cleanup|all] [--run <runId>] [--pool <name> | --hosted] [--with-lanes] [--dry-run]');
804
+ console.error('usage: node scripts/ado-acceptance.mjs --org https://dev.azure.com/<org> --source <clone> [--phase preflight|create|enqueue|exercise|heal-drill|capture|cleanup|all] [--run <runId>] [--pool <name> | --hosted] [--with-lanes] [--yes] [--dry-run]');
574
805
  process.exit(2);
575
806
  }
576
807
  const dist = (p) => import(pathToFileURL(join(ROOT, 'dist', p)).href);
577
- let azEntry, redact, runLimits;
808
+ let azEntry, redact, runLimits, userConfig;
578
809
  try {
579
810
  const { resolveAzEntry } = await dist('forge/ado/az-binary.js');
580
811
  ({ redactAdoSecrets: redact } = await dist('forge/ado/redact.js'));
@@ -584,12 +815,20 @@ async function main() {
584
815
  untrustedRoots: [o.home, ...(o.source ? [o.source] : [])],
585
816
  });
586
817
  const { resolveFactoryRunLimits } = await dist('factory/run/budget.js');
587
- const { userConfigLayers } = await dist('ship/config.js');
818
+ const { trustedUserConfigPath, userConfigLayers } = await dist('ship/config.js');
588
819
  const { parseJsonc } = await dist('utils/jsonc.js');
589
820
  runLimits = (repoDir) => {
590
821
  const file = join(repoDir, '.copilot', 'omg.jsonc');
591
822
  return resolveFactoryRunLimits(userConfigLayers().trustedUser, existsSync(file) ? parseJsonc(readFileSync(file, 'utf8')) : undefined);
592
823
  };
824
+ // The only layer the factory reads trustedAuthors from (src/forge/config.ts).
825
+ userConfig = {
826
+ path: trustedUserConfigPath(),
827
+ trustedAuthors: () => {
828
+ const list = userConfigLayers().trustedUser?.factory?.forge?.azureDevOps?.trustedAuthors;
829
+ return Array.isArray(list) ? list.filter((a) => typeof a === 'string') : [];
830
+ },
831
+ };
593
832
  } catch (error) {
594
833
  if (!o.dryRun) {
595
834
  console.error(`ado-acceptance: ${error.message}\n(build first: npm run build)`);
@@ -598,7 +837,7 @@ async function main() {
598
837
  console.log(`[dry-run] az entry unresolved (${error.message}); showing argv as plain az`);
599
838
  azEntry = { command: 'az', prefix: [], env: {} };
600
839
  }
601
- const ctx = createContext(o, { spawn: spawnSync, azEntry, redact, runLimits, sleep: (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms) });
840
+ const ctx = createContext(o, { spawn: spawnSync, azEntry, redact, runLimits, userConfig, confirm: confirmOnTty, sleep: (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms) });
602
841
  try {
603
842
  runPhases(ctx);
604
843
  } catch (error) {
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Turn a BACKLOG.md in the ExcavatorTrek shape into Azure DevOps work item
3
- * fields for the live acceptance run (scripts/ado-acceptance.mjs, ADO parity
4
- * design §6 `create`). Pure: no I/O.
2
+ * Turn a BACKLOG.md in the ExcavatorTrek shape into the ticket file of
3
+ * `omg factory enqueue` for the live acceptance run (scripts/ado-acceptance.mjs,
4
+ * phase `enqueue`). Pure: no I/O.
5
5
  *
6
6
  * The shape:
7
7
  *
@@ -90,26 +90,29 @@ export function inlineHtml(text) {
90
90
  }
91
91
 
92
92
  /**
93
- * The fields `az boards work-item create` gets for one ticket: the title
94
- * (`<key> <title>`), the description and the acceptance criteria as HTML
95
- * (`Microsoft.VSTS.Common.AcceptanceCriteria` is a User Story field of the
96
- * Agile process), and the dependencies by key.
93
+ * launch's ticket file for `omg factory enqueue --spec <spec> --file`
94
+ * (shipyard ↔ factory design §3.2): one ticket per backlog ticket, keyed by
95
+ * the lower-cased ticket key, titled `<key> <title>`, the `Depends on:` text
96
+ * and the prose as the body, one acceptance item per checkbox, and every
97
+ * dependency the backlog defines as a `blockedBy` key. A dependency on a key
98
+ * the backlog lacks is reported, not invented.
97
99
  */
98
- export function ticketToWorkItem(ticket) {
99
- const depends = ticket.dependsText ? [`<p>Depends on: ${inlineHtml(ticket.dependsText)}</p>`] : [];
100
- return {
101
- key: ticket.key,
102
- title: `${ticket.key} ${ticket.title}`,
103
- descriptionHtml: [...depends, ...ticket.description.map((p) => `<p>${inlineHtml(p)}</p>`)].join('') || `<p>${inlineHtml(ticket.title)}</p>`,
104
- acceptanceHtml: `<ul>${ticket.acceptance.map((a) => `<li>${inlineHtml(a.text)}</li>`).join('')}</ul>`,
105
- dependsOn: ticket.dependsOn,
106
- };
107
- }
108
-
109
- /** Work items for every ticket; a dependency on a key the backlog lacks is reported, not invented. */
110
- export function backlogToWorkItems(markdown) {
100
+ export function backlogToTicketFile(markdown, spec) {
111
101
  const tickets = parseBacklog(markdown);
112
102
  const keys = new Set(tickets.map((t) => t.key));
113
103
  const unknown = tickets.flatMap((t) => t.dependsOn.filter((d) => !keys.has(d)).map((d) => `${t.key} depends on ${d}, which BACKLOG.md does not define`));
114
- return { items: tickets.map(ticketToWorkItem), unknown };
104
+ return {
105
+ file: {
106
+ schemaVersion: 1,
107
+ spec,
108
+ tickets: tickets.map((t) => ({
109
+ key: t.key.toLowerCase(),
110
+ title: `${t.key} ${t.title}`,
111
+ body: [...(t.dependsText ? [`Depends on: ${t.dependsText}`] : []), ...t.description].join('\n\n') || t.title,
112
+ acceptance: t.acceptance.map((a) => a.text),
113
+ blockedBy: t.dependsOn.filter((d) => keys.has(d)).map((d) => d.toLowerCase()),
114
+ })),
115
+ },
116
+ unknown,
117
+ };
115
118
  }