@mastra/factory 0.28.0-alpha.2 → 0.28.0-alpha.3

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 (399) hide show
  1. package/README.md +244 -123
  2. package/dist/boards/board-events.d.ts +23 -3
  3. package/dist/boards/board-events.d.ts.map +1 -1
  4. package/dist/boards/board-events.js +44 -7
  5. package/dist/boards/board-events.js.map +1 -1
  6. package/dist/boards/board-writes.d.ts +1 -1
  7. package/dist/boards/board-writes.d.ts.map +1 -1
  8. package/dist/boards/board-writes.js +16 -1
  9. package/dist/boards/board-writes.js.map +1 -1
  10. package/dist/boards/card-facts.d.ts +1 -1
  11. package/dist/boards/card-facts.d.ts.map +1 -1
  12. package/dist/boards/card-facts.js +4 -0
  13. package/dist/boards/card-facts.js.map +1 -1
  14. package/dist/boards/default-board.d.ts +7 -0
  15. package/dist/boards/default-board.d.ts.map +1 -0
  16. package/dist/boards/default-board.js +10 -0
  17. package/dist/boards/default-board.js.map +1 -0
  18. package/dist/boards/define-board.d.ts +39 -17
  19. package/dist/boards/define-board.d.ts.map +1 -1
  20. package/dist/boards/define-board.js +64 -42
  21. package/dist/boards/define-board.js.map +1 -1
  22. package/dist/boards/index.d.ts +5 -8
  23. package/dist/boards/index.d.ts.map +1 -1
  24. package/dist/boards/index.js +5 -19
  25. package/dist/boards/intake-routing.d.ts +27 -5
  26. package/dist/boards/intake-routing.d.ts.map +1 -1
  27. package/dist/boards/intake-routing.js +69 -16
  28. package/dist/boards/intake-routing.js.map +1 -1
  29. package/dist/boards/legacy-plan-role.d.ts.map +1 -1
  30. package/dist/boards/legacy-plan-role.js +7 -2
  31. package/dist/boards/legacy-plan-role.js.map +1 -1
  32. package/dist/boards/phase-automation.d.ts +7 -0
  33. package/dist/boards/phase-automation.d.ts.map +1 -1
  34. package/dist/boards/phase-automation.js +16 -5
  35. package/dist/boards/phase-automation.js.map +1 -1
  36. package/dist/boards/phase-runner.d.ts +18 -10
  37. package/dist/boards/phase-runner.d.ts.map +1 -1
  38. package/dist/boards/phase-runner.js +39 -34
  39. package/dist/boards/phase-runner.js.map +1 -1
  40. package/dist/boards/project-boards.d.ts +9 -6
  41. package/dist/boards/project-boards.d.ts.map +1 -1
  42. package/dist/boards/project-boards.js +56 -18
  43. package/dist/boards/project-boards.js.map +1 -1
  44. package/dist/boards/registry.d.ts.map +1 -1
  45. package/dist/boards/registry.js +3 -1
  46. package/dist/boards/registry.js.map +1 -1
  47. package/dist/boards/relocate.d.ts +1 -1
  48. package/dist/boards/relocate.d.ts.map +1 -1
  49. package/dist/boards/relocate.js +3 -2
  50. package/dist/boards/relocate.js.map +1 -1
  51. package/dist/boards/review.d.ts +5 -2
  52. package/dist/boards/review.d.ts.map +1 -1
  53. package/dist/boards/review.js +12 -11
  54. package/dist/boards/review.js.map +1 -1
  55. package/dist/boards/semantics.d.ts +159 -20
  56. package/dist/boards/semantics.d.ts.map +1 -1
  57. package/dist/boards/semantics.js +256 -23
  58. package/dist/boards/semantics.js.map +1 -1
  59. package/dist/boards/stored-board.d.ts +32 -18
  60. package/dist/boards/stored-board.d.ts.map +1 -1
  61. package/dist/boards/stored-board.js +31 -97
  62. package/dist/boards/stored-board.js.map +1 -1
  63. package/dist/boards/work-migrations.d.ts +19 -0
  64. package/dist/boards/work-migrations.d.ts.map +1 -0
  65. package/dist/boards/work-migrations.js +257 -0
  66. package/dist/boards/work-migrations.js.map +1 -0
  67. package/dist/boards/work-routes.d.ts +53 -0
  68. package/dist/boards/work-routes.d.ts.map +1 -0
  69. package/dist/boards/work-routes.js +256 -0
  70. package/dist/boards/work-routes.js.map +1 -0
  71. package/dist/boards/work.d.ts +8 -19
  72. package/dist/boards/work.d.ts.map +1 -1
  73. package/dist/boards/work.js +38 -270
  74. package/dist/boards/work.js.map +1 -1
  75. package/dist/factory.d.ts +3 -3
  76. package/dist/factory.d.ts.map +1 -1
  77. package/dist/factory.js +58 -30
  78. package/dist/factory.js.map +1 -1
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -3
  82. package/dist/integrations/base.d.ts +6 -2
  83. package/dist/integrations/base.d.ts.map +1 -1
  84. package/dist/integrations/closing-references.d.ts +15 -0
  85. package/dist/integrations/closing-references.d.ts.map +1 -0
  86. package/dist/integrations/closing-references.js +69 -0
  87. package/dist/integrations/closing-references.js.map +1 -0
  88. package/dist/integrations/github/default-rules.d.ts +15 -66
  89. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  90. package/dist/integrations/github/default-rules.js +129 -71
  91. package/dist/integrations/github/default-rules.js.map +1 -1
  92. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
  93. package/dist/integrations/github/issue-reconciler.js +3 -1
  94. package/dist/integrations/github/issue-reconciler.js.map +1 -1
  95. package/dist/integrations/github/pull-request-source.d.ts +8 -0
  96. package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
  97. package/dist/integrations/github/pull-request-source.js +17 -0
  98. package/dist/integrations/github/pull-request-source.js.map +1 -0
  99. package/dist/integrations/github/review-status-reporter.d.ts.map +1 -1
  100. package/dist/integrations/github/review-status-reporter.js +7 -3
  101. package/dist/integrations/github/review-status-reporter.js.map +1 -1
  102. package/dist/integrations/github/routes.js +1 -1
  103. package/dist/integrations/github/rules.d.ts +13 -2
  104. package/dist/integrations/github/rules.d.ts.map +1 -1
  105. package/dist/integrations/github/rules.js +202 -34
  106. package/dist/integrations/github/rules.js.map +1 -1
  107. package/dist/integrations/github/session-subscriptions.js +2 -2
  108. package/dist/integrations/github/session-subscriptions.js.map +1 -1
  109. package/dist/integrations/github/token-refresh.d.ts +2 -1
  110. package/dist/integrations/github/token-refresh.d.ts.map +1 -1
  111. package/dist/integrations/github/token-refresh.js.map +1 -1
  112. package/dist/integrations/gitlab/agent-tools.js +1 -1
  113. package/dist/integrations/gitlab/default-rules.d.ts +73 -31
  114. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  115. package/dist/integrations/gitlab/default-rules.js +106 -43
  116. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  117. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
  118. package/dist/integrations/gitlab/issue-reconciler.js +2 -1
  119. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
  120. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
  121. package/dist/integrations/gitlab/merge-request-reconciler.js +11 -4
  122. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
  123. package/dist/integrations/gitlab/rules.d.ts +6 -1
  124. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  125. package/dist/integrations/gitlab/rules.js +116 -23
  126. package/dist/integrations/gitlab/rules.js.map +1 -1
  127. package/dist/integrations/gitlab/session-subscriptions.js +1 -1
  128. package/dist/integrations/incidentio/agent-tools.js +1 -1
  129. package/dist/integrations/incidentio/default-rules.js +3 -3
  130. package/dist/integrations/incidentio/default-rules.js.map +1 -1
  131. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
  132. package/dist/integrations/incidentio/issue-reconciler.js +2 -1
  133. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
  134. package/dist/integrations/incidentio/rules.d.ts +3 -1
  135. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  136. package/dist/integrations/incidentio/rules.js +14 -11
  137. package/dist/integrations/incidentio/rules.js.map +1 -1
  138. package/dist/integrations/jira/agent-tools.js +1 -1
  139. package/dist/integrations/jira/default-rules.js +3 -3
  140. package/dist/integrations/jira/default-rules.js.map +1 -1
  141. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
  142. package/dist/integrations/jira/issue-reconciler.js +2 -1
  143. package/dist/integrations/jira/issue-reconciler.js.map +1 -1
  144. package/dist/integrations/jira/rules.d.ts +3 -1
  145. package/dist/integrations/jira/rules.d.ts.map +1 -1
  146. package/dist/integrations/jira/rules.js +14 -11
  147. package/dist/integrations/jira/rules.js.map +1 -1
  148. package/dist/integrations/linear/agent-tools.d.ts +9 -1
  149. package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
  150. package/dist/integrations/linear/agent-tools.js +80 -2
  151. package/dist/integrations/linear/agent-tools.js.map +1 -1
  152. package/dist/integrations/linear/default-rules.js +3 -3
  153. package/dist/integrations/linear/default-rules.js.map +1 -1
  154. package/dist/integrations/linear/integration.d.ts +4 -1
  155. package/dist/integrations/linear/integration.d.ts.map +1 -1
  156. package/dist/integrations/linear/integration.js +21 -1
  157. package/dist/integrations/linear/integration.js.map +1 -1
  158. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  159. package/dist/integrations/linear/issue-reconciler.js +2 -1
  160. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  161. package/dist/integrations/linear/routes.d.ts +2 -1
  162. package/dist/integrations/linear/routes.d.ts.map +1 -1
  163. package/dist/integrations/linear/routes.js +4 -3
  164. package/dist/integrations/linear/routes.js.map +1 -1
  165. package/dist/integrations/linear/rules.d.ts +3 -1
  166. package/dist/integrations/linear/rules.d.ts.map +1 -1
  167. package/dist/integrations/linear/rules.js +15 -12
  168. package/dist/integrations/linear/rules.js.map +1 -1
  169. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  170. package/dist/integrations/platform/github/integration.js +33 -21
  171. package/dist/integrations/platform/github/integration.js.map +1 -1
  172. package/dist/integrations/platform/jira/agent-tools.js +1 -1
  173. package/dist/integrations/platform/linear/integration.d.ts +1 -1
  174. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  175. package/dist/integrations/platform/linear/integration.js +6 -5
  176. package/dist/integrations/platform/linear/integration.js.map +1 -1
  177. package/dist/integrations/slack/chat-tools.js +1 -1
  178. package/dist/integrations/slack/reply-tool.js +1 -1
  179. package/dist/integrations/slack/share-file-tool.js +1 -1
  180. package/dist/integrations/slack/slack.d.ts +10 -4
  181. package/dist/integrations/slack/slack.d.ts.map +1 -1
  182. package/dist/integrations/slack/slack.js +19 -9
  183. package/dist/integrations/slack/slack.js.map +1 -1
  184. package/dist/links.d.ts.map +1 -1
  185. package/dist/links.js +3 -2
  186. package/dist/links.js.map +1 -1
  187. package/dist/mcp/routes.js +2 -2
  188. package/dist/routes/attention-parked.d.ts +1 -0
  189. package/dist/routes/attention-parked.d.ts.map +1 -1
  190. package/dist/routes/attention-parked.js +1 -1
  191. package/dist/routes/attention-parked.js.map +1 -1
  192. package/dist/routes/automation-runs.d.ts +4 -0
  193. package/dist/routes/automation-runs.d.ts.map +1 -1
  194. package/dist/routes/automation-runs.js +15 -0
  195. package/dist/routes/automation-runs.js.map +1 -1
  196. package/dist/routes/boards.d.ts +1 -1
  197. package/dist/routes/boards.d.ts.map +1 -1
  198. package/dist/routes/boards.js +1 -17
  199. package/dist/routes/boards.js.map +1 -1
  200. package/dist/routes/config.d.ts +4 -0
  201. package/dist/routes/config.d.ts.map +1 -1
  202. package/dist/routes/config.js +15 -0
  203. package/dist/routes/config.js.map +1 -1
  204. package/dist/routes/contracts.d.ts +125 -14
  205. package/dist/routes/contracts.d.ts.map +1 -1
  206. package/dist/routes/contracts.js +34 -15
  207. package/dist/routes/contracts.js.map +1 -1
  208. package/dist/routes/fs.d.ts +4 -0
  209. package/dist/routes/fs.d.ts.map +1 -1
  210. package/dist/routes/fs.js +8 -4
  211. package/dist/routes/fs.js.map +1 -1
  212. package/dist/routes/intake-routes.d.ts.map +1 -1
  213. package/dist/routes/intake-routes.js.map +1 -1
  214. package/dist/routes/intake.d.ts.map +1 -1
  215. package/dist/routes/intake.js +1 -0
  216. package/dist/routes/intake.js.map +1 -1
  217. package/dist/routes/projects.d.ts.map +1 -1
  218. package/dist/routes/projects.js +8 -2
  219. package/dist/routes/projects.js.map +1 -1
  220. package/dist/routes/provider-credentials.d.ts.map +1 -1
  221. package/dist/routes/provider-credentials.js +10 -5
  222. package/dist/routes/provider-credentials.js.map +1 -1
  223. package/dist/routes/running-packages.d.ts +13 -0
  224. package/dist/routes/running-packages.d.ts.map +1 -0
  225. package/dist/routes/running-packages.js +45 -0
  226. package/dist/routes/running-packages.js.map +1 -0
  227. package/dist/routes/surface.d.ts +10 -1
  228. package/dist/routes/surface.d.ts.map +1 -1
  229. package/dist/routes/surface.js +104 -35
  230. package/dist/routes/surface.js.map +1 -1
  231. package/dist/routes/work-items.d.ts.map +1 -1
  232. package/dist/routes/work-items.js +23 -3
  233. package/dist/routes/work-items.js.map +1 -1
  234. package/dist/rules/binding-context.d.ts.map +1 -1
  235. package/dist/rules/binding-context.js +1 -0
  236. package/dist/rules/binding-context.js.map +1 -1
  237. package/dist/rules/dispatcher.d.ts +0 -1
  238. package/dist/rules/dispatcher.d.ts.map +1 -1
  239. package/dist/rules/dispatcher.js +340 -42
  240. package/dist/rules/dispatcher.js.map +1 -1
  241. package/dist/rules/event-rules.d.ts +33 -2
  242. package/dist/rules/event-rules.d.ts.map +1 -1
  243. package/dist/rules/event-rules.js +46 -11
  244. package/dist/rules/event-rules.js.map +1 -1
  245. package/dist/rules/index.d.ts +2 -4
  246. package/dist/rules/index.d.ts.map +1 -1
  247. package/dist/rules/index.js +2 -3
  248. package/dist/rules/phase-goal.d.ts +54 -0
  249. package/dist/rules/phase-goal.d.ts.map +1 -0
  250. package/dist/rules/phase-goal.js +70 -0
  251. package/dist/rules/phase-goal.js.map +1 -0
  252. package/dist/rules/phase-tools.d.ts +11 -0
  253. package/dist/rules/phase-tools.d.ts.map +1 -0
  254. package/dist/rules/phase-tools.js +19 -0
  255. package/dist/rules/phase-tools.js.map +1 -0
  256. package/dist/rules/processor.d.ts.map +1 -1
  257. package/dist/rules/processor.js +112 -11
  258. package/dist/rules/processor.js.map +1 -1
  259. package/dist/rules/review-source-tool.d.ts +4 -1
  260. package/dist/rules/review-source-tool.d.ts.map +1 -1
  261. package/dist/rules/review-source-tool.js +24 -4
  262. package/dist/rules/review-source-tool.js.map +1 -1
  263. package/dist/rules/rule-group.d.ts +1 -1
  264. package/dist/rules/rule-group.d.ts.map +1 -1
  265. package/dist/rules/rule-group.js +2 -1
  266. package/dist/rules/rule-group.js.map +1 -1
  267. package/dist/rules/start-coordinator.d.ts +5 -1
  268. package/dist/rules/start-coordinator.d.ts.map +1 -1
  269. package/dist/rules/start-coordinator.js +9 -3
  270. package/dist/rules/start-coordinator.js.map +1 -1
  271. package/dist/rules/tools.d.ts.map +1 -1
  272. package/dist/rules/tools.js +39 -28
  273. package/dist/rules/tools.js.map +1 -1
  274. package/dist/rules/transition-service.d.ts +2 -7
  275. package/dist/rules/transition-service.d.ts.map +1 -1
  276. package/dist/rules/transition-service.js +61 -54
  277. package/dist/rules/transition-service.js.map +1 -1
  278. package/dist/rules/types.d.ts +83 -29
  279. package/dist/rules/types.d.ts.map +1 -1
  280. package/dist/rules/types.js +5 -41
  281. package/dist/rules/types.js.map +1 -1
  282. package/dist/rules/validation.d.ts.map +1 -1
  283. package/dist/rules/validation.js +32 -2
  284. package/dist/rules/validation.js.map +1 -1
  285. package/dist/secret-encryption.d.ts +21 -0
  286. package/dist/secret-encryption.d.ts.map +1 -1
  287. package/dist/secret-encryption.js +31 -4
  288. package/dist/secret-encryption.js.map +1 -1
  289. package/dist/session/self-review-gate.d.ts +6 -2
  290. package/dist/session/self-review-gate.d.ts.map +1 -1
  291. package/dist/session/self-review-gate.js +8 -4
  292. package/dist/session/self-review-gate.js.map +1 -1
  293. package/dist/session/session-threads.d.ts +2 -3
  294. package/dist/session/session-threads.d.ts.map +1 -1
  295. package/dist/session/session-threads.js.map +1 -1
  296. package/dist/session/source-control-tools.js +1 -1
  297. package/dist/session/work-item-state-processor.d.ts +27 -0
  298. package/dist/session/work-item-state-processor.d.ts.map +1 -0
  299. package/dist/session/work-item-state-processor.js +288 -0
  300. package/dist/session/work-item-state-processor.js.map +1 -0
  301. package/dist/storage/domains/boards/base.d.ts +44 -27
  302. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  303. package/dist/storage/domains/boards/base.js +76 -121
  304. package/dist/storage/domains/boards/base.js.map +1 -1
  305. package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
  306. package/dist/storage/domains/boards/schemas.js +12 -0
  307. package/dist/storage/domains/boards/schemas.js.map +1 -1
  308. package/dist/storage/domains/work-items/base.d.ts +32 -2
  309. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  310. package/dist/storage/domains/work-items/base.js +109 -26
  311. package/dist/storage/domains/work-items/base.js.map +1 -1
  312. package/dist/storage/domains/work-items/cards.d.ts +24 -2
  313. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  314. package/dist/storage/domains/work-items/cards.js +118 -8
  315. package/dist/storage/domains/work-items/cards.js.map +1 -1
  316. package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
  317. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
  318. package/dist/storage/domains/work-items/legacy-review.js +95 -0
  319. package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
  320. package/dist/storage/domains/work-items/metrics.d.ts +12 -4
  321. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
  322. package/dist/storage/domains/work-items/metrics.js +14 -32
  323. package/dist/storage/domains/work-items/metrics.js.map +1 -1
  324. package/dist/storage/domains/work-items/work-item-schema.d.ts +2 -0
  325. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  326. package/dist/storage/domains/work-items/work-item-schema.js +5 -0
  327. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  328. package/dist/tools/approval-tools.d.ts.map +1 -1
  329. package/dist/tools/approval-tools.js +28 -9
  330. package/dist/tools/approval-tools.js.map +1 -1
  331. package/dist/tools/index.d.ts +1 -1
  332. package/dist/tools/index.js +1 -1
  333. package/dist/tools/index.js.map +1 -1
  334. package/dist/tools/messaging-tools.d.ts +3 -0
  335. package/dist/tools/messaging-tools.d.ts.map +1 -1
  336. package/dist/tools/messaging-tools.js +2 -1
  337. package/dist/tools/messaging-tools.js.map +1 -1
  338. package/dist/tools/read-tools.d.ts +8 -2
  339. package/dist/tools/read-tools.d.ts.map +1 -1
  340. package/dist/tools/read-tools.js +83 -23
  341. package/dist/tools/read-tools.js.map +1 -1
  342. package/dist/tools/reports.d.ts +1 -0
  343. package/dist/tools/reports.d.ts.map +1 -1
  344. package/dist/tools/reports.js +2 -1
  345. package/dist/tools/reports.js.map +1 -1
  346. package/dist/tools/run-watch.d.ts +1 -1
  347. package/dist/tools/run-watch.d.ts.map +1 -1
  348. package/dist/tools/run-watch.js +1 -0
  349. package/dist/tools/run-watch.js.map +1 -1
  350. package/dist/tools/sandbox-tools.js +1 -1
  351. package/dist/tools/session-tools.js +1 -1
  352. package/dist/tools/sessions-state-processor.d.ts +2 -0
  353. package/dist/tools/sessions-state-processor.d.ts.map +1 -1
  354. package/dist/tools/sessions-state-processor.js +4 -2
  355. package/dist/tools/sessions-state-processor.js.map +1 -1
  356. package/dist/tools/side-sessions.d.ts +2 -0
  357. package/dist/tools/side-sessions.d.ts.map +1 -1
  358. package/dist/tools/side-sessions.js +2 -1
  359. package/dist/tools/side-sessions.js.map +1 -1
  360. package/dist/tools/work-item-tools.js +3 -3
  361. package/dist/tools/work-item-tools.js.map +1 -1
  362. package/dist/work-item-branch.d.ts +13 -0
  363. package/dist/work-item-branch.d.ts.map +1 -1
  364. package/dist/work-item-branch.js +16 -1
  365. package/dist/work-item-branch.js.map +1 -1
  366. package/dist/work-items/create-work-item.d.ts +6 -0
  367. package/dist/work-items/create-work-item.d.ts.map +1 -1
  368. package/dist/work-items/create-work-item.js +25 -1
  369. package/dist/work-items/create-work-item.js.map +1 -1
  370. package/dist/work-items/split-migration.d.ts.map +1 -1
  371. package/dist/work-items/split-migration.js +1 -0
  372. package/dist/work-items/split-migration.js.map +1 -1
  373. package/dist/workspace.d.ts.map +1 -1
  374. package/dist/workspace.js +53 -10
  375. package/dist/workspace.js.map +1 -1
  376. package/factory-skills/configure-factory-rules/SKILL.md +11 -9
  377. package/factory-skills/factory-build/SKILL.md +64 -0
  378. package/factory-skills/factory-gitlab-rereview/SKILL.md +1 -1
  379. package/factory-skills/factory-gitlab-review/SKILL.md +2 -2
  380. package/factory-skills/factory-plan/SKILL.md +8 -10
  381. package/factory-skills/factory-rereview/SKILL.md +3 -3
  382. package/factory-skills/factory-review/SKILL.md +14 -4
  383. package/factory-skills/factory-self-review/SKILL.md +31 -11
  384. package/factory-skills/factory-triage/SKILL.md +25 -10
  385. package/package.json +10 -10
  386. package/dist/boards/index.js.map +0 -1
  387. package/dist/boards/pull-request-review.d.ts +0 -14
  388. package/dist/boards/pull-request-review.d.ts.map +0 -1
  389. package/dist/boards/pull-request-review.js +0 -81
  390. package/dist/boards/pull-request-review.js.map +0 -1
  391. package/dist/boards/work-tool-rules.d.ts +0 -8
  392. package/dist/boards/work-tool-rules.d.ts.map +0 -1
  393. package/dist/boards/work-tool-rules.js +0 -19
  394. package/dist/boards/work-tool-rules.js.map +0 -1
  395. package/dist/rules/resolve.d.ts +0 -15
  396. package/dist/rules/resolve.d.ts.map +0 -1
  397. package/dist/rules/resolve.js +0 -22
  398. package/dist/rules/resolve.js.map +0 -1
  399. package/factory-skills/factory-complete-issue/SKILL.md +0 -24
@@ -4,8 +4,22 @@ import type { RuleGroup } from '../rules/rule-group.js';
4
4
  * webhooks onto these. Status events change where a card belongs: only these can move a card, so
5
5
  * only these may be named in a route's `on`.
6
6
  */
7
- export declare const STATUS_EVENTS: readonly ['work_item.created', 'work_item.closed', 'work_item.reopened'];
7
+ export declare const STATUS_EVENTS: readonly ['work_item.created', 'work_item.closed', 'work_item.reopened', 'pull_request.opened', 'pull_request.synchronized', 'pull_request.review_requested', 'pull_request.merged', 'pull_request.closed'];
8
8
  export type StatusEvent = (typeof STATUS_EVENTS)[number];
9
+ /**
10
+ * What happened to a card's pull request (GitHub) or merge request (GitLab): opened by the card's
11
+ * session, pushed to, re-review requested, merged, or closed unmerged. A provider's default rule
12
+ * decides whether the event moves the card at all; a route on the card's board naming the event
13
+ * decides where it goes.
14
+ */
15
+ export type PullRequestEvent = Extract<StatusEvent, `pull_request.${string}`>;
16
+ export declare function isPullRequestEvent(type: StatusEvent): type is PullRequestEvent;
17
+ /**
18
+ * Whether the event may move a card that is, or isn't, finished: a reopen moves only a finished
19
+ * card, a close or a merge only an unfinished one. A push or a review request re-reviews a pull
20
+ * request whatever its card's phase.
21
+ */
22
+ export declare function eventMovesCard(type: StatusEvent, finished: boolean): boolean;
9
23
  /** Activity on a card: it never moves the card, it only tells the card's session. */
10
24
  export declare const ACTIVITY_EVENTS: readonly ['work_item.commented', 'work_item.edited'];
11
25
  export type ActivityEvent = (typeof ACTIVITY_EVENTS)[number];
@@ -23,12 +37,18 @@ export declare function closeReason(canceled: boolean): CloseReason;
23
37
  export declare const DEFAULT_ROUTE_EVENTS: readonly StatusEvent[];
24
38
  /** Facts a route's `when` can test about the event, besides the card's own facts. */
25
39
  export declare const EVENT_RULE_FIELDS: readonly ['event.type', 'event.reason'];
40
+ /**
41
+ * Facts a route can test about the issue an arriving pull request closes (see
42
+ * `closedIssueRuleFacts`). Only arrivals have them, so phase conditions can't name them.
43
+ */
44
+ export declare const CLOSED_ISSUE_RULE_FIELDS: readonly ['pullRequest.closesIssue', 'closedIssue.phase', 'closedIssue.hasPullRequest'];
26
45
  /** Every field an intake route's `when` may name. */
27
- export declare const INTAKE_ROUTE_RULE_FIELDS: readonly ["item.labels", "item.title", "item.author", "author.trusted", "source.kind", "source.integration", "event.type", "event.reason"];
46
+ export declare const INTAKE_ROUTE_RULE_FIELDS: readonly ["item.labels", "item.title", "item.author", "author.trusted", "source.kind", "source.integration", "item.pullRequest", "event.type", "event.reason", "pullRequest.closesIssue", "closedIssue.phase", "closedIssue.hasPullRequest"];
28
47
  /**
29
48
  * Why a route's `on` and `when` can't be saved together, or null. `on` must name at least one
30
49
  * status event, each once; `event.*` conditions need an event besides `work_item.created`, which
31
- * places new cards and carries no event facts.
50
+ * places new cards and carries no event facts, and `event.reason` needs `work_item.closed`, the
51
+ * only event with a reason.
32
52
  */
33
53
  export declare function routeEventsProblem(on: readonly string[], when: RuleGroup | null): string | null;
34
54
  //# sourceMappingURL=board-events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"board-events.d.ts","sourceRoot":"","sources":["../../src/boards/board-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAI,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,CAAU,CAAC;AACtG,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,qFAAqF;AACrF,eAAO,MAAM,eAAe,YAAI,qBAAqB,EAAE,kBAAkB,CAAU,CAAC;AACpF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,8EAA8E;AAC9E,eAAO,MAAM,aAAa,YAAI,WAAW,EAAE,UAAU,CAAU,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,uCAAuC;AACvC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,CAE1D;AAED,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,EAAE,SAAS,WAAW,EAA0B,CAAC;AAElF,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,YAAI,YAAY,EAAE,cAAc,CAAU,CAAC;AAEzE,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,4IAAuD,CAAC;AAc7F;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAa/F"}
1
+ {"version":3,"file":"board-events.d.ts","sourceRoot":"","sources":["../../src/boards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YAAI,YAAY,EAAE,cAAc,CAAU,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,YACnC,yBAAyB,EACzB,mBAAmB,EACnB,4BAA4B,CACpB,CAAC;AAEX,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,8OAI3B,CAAC;AAYX;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAgB/F"}
@@ -8,8 +8,30 @@ import { CARD_RULE_FIELDS } from "../rules/rule-group.js";
8
8
  const STATUS_EVENTS = [
9
9
  "work_item.created",
10
10
  "work_item.closed",
11
- "work_item.reopened"
11
+ "work_item.reopened",
12
+ "pull_request.opened",
13
+ "pull_request.synchronized",
14
+ "pull_request.review_requested",
15
+ "pull_request.merged",
16
+ "pull_request.closed"
12
17
  ];
18
+ function isPullRequestEvent(type) {
19
+ return type.startsWith("pull_request.");
20
+ }
21
+ /**
22
+ * Whether the event may move a card that is, or isn't, finished: a reopen moves only a finished
23
+ * card, a close or a merge only an unfinished one. A push or a review request re-reviews a pull
24
+ * request whatever its card's phase.
25
+ */
26
+ function eventMovesCard(type, finished) {
27
+ switch (type) {
28
+ case "work_item.reopened": return finished;
29
+ case "work_item.closed":
30
+ case "pull_request.merged":
31
+ case "pull_request.closed": return !finished;
32
+ default: return true;
33
+ }
34
+ }
13
35
  /** Activity on a card: it never moves the card, it only tells the card's session. */
14
36
  const ACTIVITY_EVENTS = ["work_item.commented", "work_item.edited"];
15
37
  /** Why a work item closed: `canceled` covers "not planned" and duplicates. */
@@ -22,18 +44,32 @@ function closeReason(canceled) {
22
44
  const DEFAULT_ROUTE_EVENTS = ["work_item.created"];
23
45
  /** Facts a route's `when` can test about the event, besides the card's own facts. */
24
46
  const EVENT_RULE_FIELDS = ["event.type", "event.reason"];
47
+ /**
48
+ * Facts a route can test about the issue an arriving pull request closes (see
49
+ * `closedIssueRuleFacts`). Only arrivals have them, so phase conditions can't name them.
50
+ */
51
+ const CLOSED_ISSUE_RULE_FIELDS = [
52
+ "pullRequest.closesIssue",
53
+ "closedIssue.phase",
54
+ "closedIssue.hasPullRequest"
55
+ ];
25
56
  /** Every field an intake route's `when` may name. */
26
- const INTAKE_ROUTE_RULE_FIELDS = [...CARD_RULE_FIELDS, ...EVENT_RULE_FIELDS];
57
+ const INTAKE_ROUTE_RULE_FIELDS = [
58
+ ...CARD_RULE_FIELDS,
59
+ ...EVENT_RULE_FIELDS,
60
+ ...CLOSED_ISSUE_RULE_FIELDS
61
+ ];
27
62
  function isStatusEvent(value) {
28
63
  return STATUS_EVENTS.includes(value);
29
64
  }
30
- function namesEventField(group) {
31
- return group.conditions.some((condition) => "conditions" in condition ? namesEventField(condition) : EVENT_RULE_FIELDS.includes(condition.field));
65
+ function namesField(group, fields) {
66
+ return group.conditions.some((condition) => "conditions" in condition ? namesField(condition, fields) : fields.includes(condition.field));
32
67
  }
33
68
  /**
34
69
  * Why a route's `on` and `when` can't be saved together, or null. `on` must name at least one
35
70
  * status event, each once; `event.*` conditions need an event besides `work_item.created`, which
36
- * places new cards and carries no event facts.
71
+ * places new cards and carries no event facts, and `event.reason` needs `work_item.closed`, the
72
+ * only event with a reason.
37
73
  */
38
74
  function routeEventsProblem(on, when) {
39
75
  if (on.length === 0) return "`on` must name at least one event.";
@@ -42,9 +78,10 @@ function routeEventsProblem(on, when) {
42
78
  if (ACTIVITY_EVENTS.includes(event)) return `"${event}" is activity, not a status change: it notifies the card's session and can't move a card, so a route can't name it.`;
43
79
  if (!isStatusEvent(event)) return `"${event}" is not a board event; use one of ${STATUS_EVENTS.join(", ")}.`;
44
80
  }
45
- if (when && on.every((event) => event === "work_item.created") && namesEventField(when)) return "`event.type` and `event.reason` only apply to routes that handle an event besides work_item.created.";
81
+ if (when && on.every((event) => event === "work_item.created") && namesField(when, EVENT_RULE_FIELDS)) return "`event.type` and `event.reason` only apply to routes that handle an event besides work_item.created.";
82
+ if (when && !on.includes("work_item.closed") && namesField(when, ["event.reason"])) return "`event.reason` only applies to routes that handle work_item.closed: no other event carries a reason.";
46
83
  return null;
47
84
  }
48
- export { ACTIVITY_EVENTS, CLOSE_REASONS, DEFAULT_ROUTE_EVENTS, EVENT_RULE_FIELDS, INTAKE_ROUTE_RULE_FIELDS, STATUS_EVENTS, closeReason, routeEventsProblem };
85
+ export { ACTIVITY_EVENTS, CLOSED_ISSUE_RULE_FIELDS, CLOSE_REASONS, DEFAULT_ROUTE_EVENTS, EVENT_RULE_FIELDS, INTAKE_ROUTE_RULE_FIELDS, STATUS_EVENTS, closeReason, eventMovesCard, isPullRequestEvent, routeEventsProblem };
49
86
 
50
87
  //# sourceMappingURL=board-events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"board-events.js","names":[],"sources":["../../src/boards/board-events.ts"],"sourcesContent":["import type { RuleGroup } from '../rules/rule-group.js';\nimport { CARD_RULE_FIELDS } from '../rules/rule-group.js';\n\n/**\n * What happened to a card's source, named the same for every provider. Integrations map their\n * webhooks onto these. Status events change where a card belongs: only these can move a card, so\n * only these may be named in a route's `on`.\n */\nexport const STATUS_EVENTS = ['work_item.created', 'work_item.closed', 'work_item.reopened'] as const;\nexport type StatusEvent = (typeof STATUS_EVENTS)[number];\n\n/** Activity on a card: it never moves the card, it only tells the card's session. */\nexport const ACTIVITY_EVENTS = ['work_item.commented', 'work_item.edited'] as const;\nexport type ActivityEvent = (typeof ACTIVITY_EVENTS)[number];\n\n/** Why a work item closed: `canceled` covers \"not planned\" and duplicates. */\nexport const CLOSE_REASONS = ['completed', 'canceled'] as const;\nexport type CloseReason = (typeof CLOSE_REASONS)[number];\n\n/** A status event as routes see it. */\nexport interface BoardEventFacts {\n type: StatusEvent;\n reason?: CloseReason;\n}\n\n/** The close reason for a provider's own closed-state fact. */\nexport function closeReason(canceled: boolean): CloseReason {\n return canceled ? 'canceled' : 'completed';\n}\n\n/** What a route without `on` handles: placing new cards, as routes always have. */\nexport const DEFAULT_ROUTE_EVENTS: readonly StatusEvent[] = ['work_item.created'];\n\n/** Facts a route's `when` can test about the event, besides the card's own facts. */\nexport const EVENT_RULE_FIELDS = ['event.type', 'event.reason'] as const;\n\n/** Every field an intake route's `when` may name. */\nexport const INTAKE_ROUTE_RULE_FIELDS = [...CARD_RULE_FIELDS, ...EVENT_RULE_FIELDS] as const;\n\nfunction isStatusEvent(value: string): value is StatusEvent {\n return (STATUS_EVENTS as readonly string[]).includes(value);\n}\n\nfunction namesEventField(group: RuleGroup): boolean {\n return group.conditions.some(condition =>\n 'conditions' in condition\n ? namesEventField(condition)\n : (EVENT_RULE_FIELDS as readonly string[]).includes(condition.field),\n );\n}\n\n/**\n * Why a route's `on` and `when` can't be saved together, or null. `on` must name at least one\n * status event, each once; `event.*` conditions need an event besides `work_item.created`, which\n * places new cards and carries no event facts.\n */\nexport function routeEventsProblem(on: readonly string[], when: RuleGroup | null): string | null {\n if (on.length === 0) return '`on` must name at least one event.';\n if (new Set(on).size !== on.length) return '`on` may name each event only once.';\n for (const event of on) {\n if ((ACTIVITY_EVENTS as readonly string[]).includes(event)) {\n return `\"${event}\" is activity, not a status change: it notifies the card's session and can't move a card, so a route can't name it.`;\n }\n if (!isStatusEvent(event)) return `\"${event}\" is not a board event; use one of ${STATUS_EVENTS.join(', ')}.`;\n }\n if (when && on.every(event => event === 'work_item.created') && namesEventField(when)) {\n return '`event.type` and `event.reason` only apply to routes that handle an event besides work_item.created.';\n }\n return null;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gBAAgB;CAAC;CAAqB;CAAoB;AAAoB;;AAI3F,MAAa,kBAAkB,CAAC,uBAAuB,kBAAkB;;AAIzE,MAAa,gBAAgB,CAAC,aAAa,UAAU;;AAUrD,SAAgB,YAAY,UAAgC;CAC1D,OAAO,WAAW,aAAa;AACjC;;AAGA,MAAa,uBAA+C,CAAC,mBAAmB;;AAGhF,MAAa,oBAAoB,CAAC,cAAc,cAAc;;AAG9D,MAAa,2BAA2B,CAAC,GAAG,kBAAkB,GAAG,iBAAiB;AAElF,SAAS,cAAc,OAAqC;CAC1D,OAAQ,cAAoC,SAAS,KAAK;AAC5D;AAEA,SAAS,gBAAgB,OAA2B;CAClD,OAAO,MAAM,WAAW,MAAK,cAC3B,gBAAgB,YACZ,gBAAgB,SAAS,IACxB,kBAAwC,SAAS,UAAU,KAAK,CACvE;AACF;;;;;;AAOA,SAAgB,mBAAmB,IAAuB,MAAuC;CAC/F,IAAI,GAAG,WAAW,GAAG,OAAO;CAC5B,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,SAAS,GAAG,QAAQ,OAAO;CAC3C,KAAK,MAAM,SAAS,IAAI;EACtB,IAAK,gBAAsC,SAAS,KAAK,GACvD,OAAO,IAAI,MAAM;EAEnB,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO,IAAI,MAAM,qCAAqC,cAAc,KAAK,IAAI,EAAE;CAC5G;CACA,IAAI,QAAQ,GAAG,OAAM,UAAS,UAAU,mBAAmB,KAAK,gBAAgB,IAAI,GAClF,OAAO;CAET,OAAO;AACT"}
1
+ {"version":3,"file":"board-events.js","names":[],"sources":["../../src/boards/board-events.ts"],"sourcesContent":["import type { RuleGroup } from '../rules/rule-group.js';\nimport { CARD_RULE_FIELDS } from '../rules/rule-group.js';\n\n/**\n * What happened to a card's source, named the same for every provider. Integrations map their\n * webhooks onto these. Status events change where a card belongs: only these can move a card, so\n * only these may be named in a route's `on`.\n */\nexport const STATUS_EVENTS = [\n 'work_item.created',\n 'work_item.closed',\n 'work_item.reopened',\n 'pull_request.opened',\n 'pull_request.synchronized',\n 'pull_request.review_requested',\n 'pull_request.merged',\n 'pull_request.closed',\n] as const;\nexport type StatusEvent = (typeof STATUS_EVENTS)[number];\n\n/**\n * What happened to a card's pull request (GitHub) or merge request (GitLab): opened by the card's\n * session, pushed to, re-review requested, merged, or closed unmerged. A provider's default rule\n * decides whether the event moves the card at all; a route on the card's board naming the event\n * decides where it goes.\n */\nexport type PullRequestEvent = Extract<StatusEvent, `pull_request.${string}`>;\n\nexport function isPullRequestEvent(type: StatusEvent): type is PullRequestEvent {\n return type.startsWith('pull_request.');\n}\n\n/**\n * Whether the event may move a card that is, or isn't, finished: a reopen moves only a finished\n * card, a close or a merge only an unfinished one. A push or a review request re-reviews a pull\n * request whatever its card's phase.\n */\nexport function eventMovesCard(type: StatusEvent, finished: boolean): boolean {\n switch (type) {\n case 'work_item.reopened':\n return finished;\n case 'work_item.closed':\n case 'pull_request.merged':\n case 'pull_request.closed':\n return !finished;\n default:\n return true;\n }\n}\n\n/** Activity on a card: it never moves the card, it only tells the card's session. */\nexport const ACTIVITY_EVENTS = ['work_item.commented', 'work_item.edited'] as const;\nexport type ActivityEvent = (typeof ACTIVITY_EVENTS)[number];\n\n/** Why a work item closed: `canceled` covers \"not planned\" and duplicates. */\nexport const CLOSE_REASONS = ['completed', 'canceled'] as const;\nexport type CloseReason = (typeof CLOSE_REASONS)[number];\n\n/** A status event as routes see it. */\nexport interface BoardEventFacts {\n type: StatusEvent;\n reason?: CloseReason;\n}\n\n/** The close reason for a provider's own closed-state fact. */\nexport function closeReason(canceled: boolean): CloseReason {\n return canceled ? 'canceled' : 'completed';\n}\n\n/** What a route without `on` handles: placing new cards, as routes always have. */\nexport const DEFAULT_ROUTE_EVENTS: readonly StatusEvent[] = ['work_item.created'];\n\n/** Facts a route's `when` can test about the event, besides the card's own facts. */\nexport const EVENT_RULE_FIELDS = ['event.type', 'event.reason'] as const;\n\n/**\n * Facts a route can test about the issue an arriving pull request closes (see\n * `closedIssueRuleFacts`). Only arrivals have them, so phase conditions can't name them.\n */\nexport const CLOSED_ISSUE_RULE_FIELDS = [\n 'pullRequest.closesIssue',\n 'closedIssue.phase',\n 'closedIssue.hasPullRequest',\n] as const;\n\n/** Every field an intake route's `when` may name. */\nexport const INTAKE_ROUTE_RULE_FIELDS = [\n ...CARD_RULE_FIELDS,\n ...EVENT_RULE_FIELDS,\n ...CLOSED_ISSUE_RULE_FIELDS,\n] as const;\n\nfunction isStatusEvent(value: string): value is StatusEvent {\n return (STATUS_EVENTS as readonly string[]).includes(value);\n}\n\nfunction namesField(group: RuleGroup, fields: readonly string[]): boolean {\n return group.conditions.some(condition =>\n 'conditions' in condition ? namesField(condition, fields) : fields.includes(condition.field),\n );\n}\n\n/**\n * Why a route's `on` and `when` can't be saved together, or null. `on` must name at least one\n * status event, each once; `event.*` conditions need an event besides `work_item.created`, which\n * places new cards and carries no event facts, and `event.reason` needs `work_item.closed`, the\n * only event with a reason.\n */\nexport function routeEventsProblem(on: readonly string[], when: RuleGroup | null): string | null {\n if (on.length === 0) return '`on` must name at least one event.';\n if (new Set(on).size !== on.length) return '`on` may name each event only once.';\n for (const event of on) {\n if ((ACTIVITY_EVENTS as readonly string[]).includes(event)) {\n return `\"${event}\" is activity, not a status change: it notifies the card's session and can't move a card, so a route can't name it.`;\n }\n if (!isStatusEvent(event)) return `\"${event}\" is not a board event; use one of ${STATUS_EVENTS.join(', ')}.`;\n }\n if (when && on.every(event => event === 'work_item.created') && namesField(when, EVENT_RULE_FIELDS)) {\n return '`event.type` and `event.reason` only apply to routes that handle an event besides work_item.created.';\n }\n if (when && !on.includes('work_item.closed') && namesField(when, ['event.reason'])) {\n return '`event.reason` only applies to routes that handle work_item.closed: no other event carries a reason.';\n }\n return null;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAWA,SAAgB,mBAAmB,MAA6C;CAC9E,OAAO,KAAK,WAAW,eAAe;AACxC;;;;;;AAOA,SAAgB,eAAe,MAAmB,UAA4B;CAC5E,QAAQ,MAAR;EACE,KAAK,sBACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,uBACH,OAAO,CAAC;EACV,SACE,OAAO;CACX;AACF;;AAGA,MAAa,kBAAkB,CAAC,uBAAuB,kBAAkB;;AAIzE,MAAa,gBAAgB,CAAC,aAAa,UAAU;;AAUrD,SAAgB,YAAY,UAAgC;CAC1D,OAAO,WAAW,aAAa;AACjC;;AAGA,MAAa,uBAA+C,CAAC,mBAAmB;;AAGhF,MAAa,oBAAoB,CAAC,cAAc,cAAc;;;;;AAM9D,MAAa,2BAA2B;CACtC;CACA;CACA;AACF;;AAGA,MAAa,2BAA2B;CACtC,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAEA,SAAS,cAAc,OAAqC;CAC1D,OAAQ,cAAoC,SAAS,KAAK;AAC5D;AAEA,SAAS,WAAW,OAAkB,QAAoC;CACxE,OAAO,MAAM,WAAW,MAAK,cAC3B,gBAAgB,YAAY,WAAW,WAAW,MAAM,IAAI,OAAO,SAAS,UAAU,KAAK,CAC7F;AACF;;;;;;;AAQA,SAAgB,mBAAmB,IAAuB,MAAuC;CAC/F,IAAI,GAAG,WAAW,GAAG,OAAO;CAC5B,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,SAAS,GAAG,QAAQ,OAAO;CAC3C,KAAK,MAAM,SAAS,IAAI;EACtB,IAAK,gBAAsC,SAAS,KAAK,GACvD,OAAO,IAAI,MAAM;EAEnB,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO,IAAI,MAAM,qCAAqC,cAAc,KAAK,IAAI,EAAE;CAC5G;CACA,IAAI,QAAQ,GAAG,OAAM,UAAS,UAAU,mBAAmB,KAAK,WAAW,MAAM,iBAAiB,GAChG,OAAO;CAET,IAAI,QAAQ,CAAC,GAAG,SAAS,kBAAkB,KAAK,WAAW,MAAM,CAAC,cAAc,CAAC,GAC/E,OAAO;CAET,OAAO;AACT"}
@@ -43,7 +43,7 @@ export declare class BoardWrites {
43
43
  constructor(deps: BoardWritesDeps);
44
44
  /**
45
45
  * Code boards can't be created over, and Work can't be deleted while its code handlers run by its
46
- * key; the legacy Review board can't be changed at all.
46
+ * key; the retired Review board's key can't be used at all.
47
47
  */
48
48
  refuseCodeBoard(key: string, action: 'create' | 'edit' | 'delete'): void;
49
49
  existing(scope: StoredBoardScope, key: string): Promise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AE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQrG;IAED;;;;;OAKG;IACG,MAAM,CACV,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC,CA2B/C;IAED;;;OAGG;IACG,OAAO,CACX,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,EACzC,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAC9E,OAAO,CAAC;QAAE,GAAG,EAAE,iBAAiB,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAmBvD;IAED,mDAAmD;IAC7C,MAAM,CACV,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAC9E,OAAO,CAAC,IAAI,CAAC,CAgBf;IAED,mGAAmG;IAC7F,KAAK,CACT,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAC9E,OAAO,CAAC,iBAAiB,CAAC,CAkB5B;CA+CF"}
@@ -1,5 +1,6 @@
1
1
  import { findBoardSkillProblems } from "../skills/app-skills.js";
2
2
  import { StoredBoardError } from "../storage/domains/boards/base.js";
3
+ import "../storage/domains/work-items/legacy-review.js";
3
4
  import { codeBoardOf } from "./define-board.js";
4
5
  import { createBoardRegistry } from "./registry.js";
5
6
  import { boardForWorkItem } from "./semantics.js";
@@ -37,6 +38,17 @@ async function stored(write) {
37
38
  throw error;
38
39
  }
39
40
  }
41
+ /**
42
+ * The retired Review board's key is never written: a project still using it is served it from
43
+ * code, and a board under its key elsewhere would take over the cards stored there.
44
+ */
45
+ function refuseReservedBoard(key) {
46
+ if (key !== "review") return;
47
+ throw new BoardWriteError(409, {
48
+ error: "reserved_board",
49
+ message: `Board "${key}" is reserved for the retired Review board.`
50
+ });
51
+ }
40
52
  var BoardWrites = class {
41
53
  deps;
42
54
  constructor(deps) {
@@ -44,9 +56,10 @@ var BoardWrites = class {
44
56
  }
45
57
  /**
46
58
  * Code boards can't be created over, and Work can't be deleted while its code handlers run by its
47
- * key; the legacy Review board can't be changed at all.
59
+ * key; the retired Review board's key can't be used at all.
48
60
  */
49
61
  refuseCodeBoard(key, action) {
62
+ refuseReservedBoard(key);
50
63
  const { boards } = this.deps;
51
64
  const code = boards.codeRegistry.get(key);
52
65
  if (!code) return;
@@ -77,6 +90,7 @@ var BoardWrites = class {
77
90
  error: "invalid_board",
78
91
  message: issueMessage(parsed.error.issues)
79
92
  });
93
+ refuseReservedBoard(parsed.data.key);
80
94
  const code = boards.seedFor(parsed.data.key) && boards.codeRegistry.get(parsed.data.key);
81
95
  if (code) {
82
96
  const conflicts = codeBehaviourConflicts(parsed.data, code);
@@ -114,6 +128,7 @@ var BoardWrites = class {
114
128
  * with another one rereads and tries again.
115
129
  */
116
130
  async upsert(scope, board, writer) {
131
+ refuseReservedBoard(board.key);
117
132
  const { storage, boards } = this.deps;
118
133
  await boards.describe(scope);
119
134
  for (let attempt = 1;; attempt++) {
@@ -1 +1 @@
1
- {"version":3,"file":"board-writes.js","names":[],"sources":["../../src/boards/board-writes.ts"],"sourcesContent":["/**\n * Writes to a project's stored boards, shared by the boards API and `MastraFactory#upsertBoard()`.\n *\n * Every write is checked against the rules `defineBoard()` enforces, the skills its runners name,\n * the code behaviour of a code board's copy, and the cards sitting on the board. It then\n * invalidates the project's board cache and records an audit event.\n */\n\nimport type { z } from 'zod';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type { EmitAuditInput } from '../storage/domains/audit/domain.js';\nimport { StoredBoardError } from '../storage/domains/boards/base.js';\nimport type {\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n StoredPhaseInput,\n} from '../storage/domains/boards/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { codeBoardOf } from './define-board.js';\nimport type { ProjectBoardCache } from './project-boards.js';\nimport { createBoardRegistry } from './registry.js';\nimport { boardForWorkItem } from './semantics.js';\nimport {\n codeBehaviourConflicts,\n compileStoredBoard,\n sameBoardDefinition,\n storedBoardInputSchema,\n} from './stored-board.js';\nimport { workBoard } from './work.js';\n\nexport interface BoardWritesDeps {\n storage: StoredBoardsStorage;\n /** The per-project boards: the code boards and their seeds, skills, and the cache to invalidate. */\n boards: Pick<ProjectBoardCache, 'describe' | 'invalidate' | 'codeRegistry' | 'codeSkills' | 'seedFor'>;\n /** Read to refuse edits that would strand cards. */\n workItems: Pick<WorkItemsStorage, 'list'>;\n}\n\n/** Who writes: stored as the board's author, and the audit event's actor. */\nexport interface BoardWriter {\n id: string;\n audit(input: EmitAuditInput): Promise<void>;\n}\n\n/** A refused board write. `status` and `body` are what the boards API answers with. */\nexport class BoardWriteError extends Error {\n override name = 'BoardWriteError';\n constructor(\n readonly status: 404 | 409 | 422,\n readonly body: { error: string; message?: string } & Record<string, unknown>,\n ) {\n super(body.message ?? body.error);\n }\n\n get code(): string {\n return this.body.error;\n }\n}\n\nexport function issueMessage(issues: readonly z.core.$ZodIssue[]): string {\n return issues\n .map(issue => (issue.path.length > 0 ? `${issue.path.join('.')}: ${issue.message}` : issue.message))\n .join('; ');\n}\n\nconst UNKNOWN_SKILL = 'but no such skill exists';\nconst UPSERT_ATTEMPTS = 3;\n\n/** Storage refusals (a stale revision, a missing or existing board) as board write errors. */\nasync function stored<T>(write: () => Promise<T>): Promise<T> {\n try {\n return await write();\n } catch (error) {\n if (error instanceof StoredBoardError) {\n throw new BoardWriteError(error.code === 'board_not_found' ? 404 : 409, {\n error: error.code,\n message: error.message,\n });\n }\n throw error;\n }\n}\n\nexport class BoardWrites {\n constructor(private readonly deps: BoardWritesDeps) {}\n\n /**\n * Code boards can't be created over, and Work can't be deleted while its code handlers run by its\n * key; the legacy Review board can't be changed at all.\n */\n refuseCodeBoard(key: string, action: 'create' | 'edit' | 'delete'): void {\n const { boards } = this.deps;\n const code = boards.codeRegistry.get(key);\n if (!code) return;\n const stored = boards.seedFor(key) !== undefined;\n if (action === 'edit' && stored) return;\n if (action === 'delete' && stored && codeBoardOf(code) !== workBoard) return;\n throw new BoardWriteError(409, {\n error: 'code_board',\n message:\n action === 'delete' && stored\n ? `Board \"${key}\" is defined in code and can't be deleted; reset it to its default instead.`\n : `Board \"${key}\" is defined in code and can't be ${action === 'create' ? 'created over' : 'changed'} here.`,\n });\n }\n\n async existing(scope: StoredBoardScope, key: string): Promise<StoredBoardRecord> {\n const row = await this.deps.storage.get(scope, key);\n if (!row) throw new BoardWriteError(404, { error: 'board_not_found', message: `Board \"${key}\" does not exist.` });\n return row;\n }\n\n /**\n * Validates a definition the way `defineBoard()` does, plus the skills its runners name. A code\n * board's copy is also checked against the code behaviour of its board and phase keys.\n */\n validate(input: unknown): StoredBoardInput {\n const { boards } = this.deps;\n const parsed = storedBoardInputSchema.safeParse(input);\n if (!parsed.success) {\n throw new BoardWriteError(422, { error: 'invalid_board', message: issueMessage(parsed.error.issues) });\n }\n const code = boards.seedFor(parsed.data.key) && boards.codeRegistry.get(parsed.data.key);\n if (code) {\n const conflicts = codeBehaviourConflicts(parsed.data, code);\n if (conflicts.length > 0) {\n throw new BoardWriteError(422, { error: 'code_behaviour', message: conflicts.join(' '), conflicts });\n }\n }\n const board = code ? compileStoredBoard(parsed.data, code) : compileStoredBoard(parsed.data);\n const problems = findBoardSkillProblems(\n createBoardRegistry({ boards: [board], includeDefaultBoards: false }),\n boards.codeSkills,\n );\n const unknown = problems.filter(problem => problem.includes(UNKNOWN_SKILL));\n if (unknown.length > 0) throw new BoardWriteError(422, { error: 'unknown_skill', message: unknown.join(' ') });\n return parsed.data;\n }\n\n /** Creates a board under a key no code board uses. */\n async create(scope: StoredBoardScope, input: unknown, writer: BoardWriter): Promise<StoredBoardRecord> {\n const key = (input as { key?: unknown } | null)?.key;\n if (typeof key === 'string') this.refuseCodeBoard(key, 'create');\n const board = this.validate(input);\n const row = await stored(() => this.deps.storage.create(scope, board, writer.id));\n this.deps.boards.invalidate(scope);\n await this.#audit(scope, writer, 'created', board);\n return row;\n }\n\n /**\n * Stores a validated board in a project, after its first load stored Factory's boards: creates\n * it when the project has none under its key, and otherwise replaces the project's board, edited\n * or not, at its current revision, with the same checks as an edit. A write that loses a race\n * with another one rereads and tries again.\n */\n async upsert(\n scope: StoredBoardScope,\n board: StoredBoardInput,\n writer: BoardWriter,\n ): Promise<'inserted' | 'updated' | 'unchanged'> {\n const { storage, boards } = this.deps;\n await boards.describe(scope);\n for (let attempt = 1; ; attempt++) {\n const row = await storage.get(scope, board.key);\n try {\n if (!row) {\n if (!(await storage.insertIfMissing(scope, board, writer.id))) {\n throw new BoardWriteError(409, {\n error: 'revision_mismatch',\n message: `Board \"${board.key}\" was stored by another write; try again.`,\n });\n }\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'created', board);\n return 'inserted';\n }\n const { key, ...definition } = board;\n const { written } = await this.replace(scope, key, definition, { expectedRevision: row.revision, writer });\n return written ? 'updated' : 'unchanged';\n } catch (error) {\n const lost =\n error instanceof BoardWriteError && (error.code === 'revision_mismatch' || error.code === 'board_not_found');\n if (!lost || attempt >= UPSERT_ATTEMPTS) throw error;\n }\n }\n }\n\n /**\n * Replaces a board's definition at `expectedRevision`. Saving it unchanged writes nothing;\n * `written` says whether anything was stored.\n */\n async replace(\n scope: StoredBoardScope,\n key: string,\n definition: Omit<StoredBoardInput, 'key'>,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<{ row: StoredBoardRecord; written: boolean }> {\n const { storage, boards } = this.deps;\n this.refuseCodeBoard(key, 'edit');\n const seed = boards.seedFor(key);\n // The project's first load stores Factory's boards.\n if (seed) await boards.describe(scope);\n const row = await this.existing(scope, key);\n const input = this.validate({ key, ...definition });\n if (row.revision === expectedRevision && sameBoardDefinition(row, input)) {\n return { row, written: false };\n }\n await this.#checkPhasesFree(scope, row, input.phases);\n const { key: _key, ...replacement } = input;\n const replaced = await stored(() =>\n storage.replace(scope, key, replacement, { expectedRevision, actor: writer.id }),\n );\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'updated', input);\n return { row: replaced, written: true };\n }\n\n /** Deletes a stored board that no card sits on. */\n async remove(\n scope: StoredBoardScope,\n key: string,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<void> {\n this.refuseCodeBoard(key, 'delete');\n // The project's first load stores Factory's boards.\n if (this.deps.boards.seedFor(key)) await this.deps.boards.describe(scope);\n const row = await this.existing(scope, key);\n const { cards } = await this.#occupancy(scope, key);\n if (cards > 0) {\n throw new BoardWriteError(409, {\n error: 'board_in_use',\n message: `Board \"${key}\" still has cards; move or delete them first.`,\n cards,\n });\n }\n await stored(() => this.deps.storage.delete(scope, key, { expectedRevision }));\n this.deps.boards.invalidate(scope);\n await this.#audit(scope, writer, 'deleted', row);\n }\n\n /** Rewrites a board Factory stores to Factory's current definition of it, at the next revision. */\n async reset(\n scope: StoredBoardScope,\n key: string,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<StoredBoardRecord> {\n const { storage, boards } = this.deps;\n const seed = boards.seedFor(key);\n if (!seed) {\n this.refuseCodeBoard(key, 'edit');\n await this.existing(scope, key);\n throw new BoardWriteError(409, {\n error: 'not_code_board',\n message: `Board \"${key}\" was created in this project and has no default to reset to.`,\n });\n }\n await boards.describe(scope);\n const row = await this.existing(scope, key);\n await this.#checkPhasesFree(scope, row, seed.phases);\n const reset = await stored(() => storage.resetTo(scope, key, seed, { expectedRevision, actor: writer.id }));\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'reset', row);\n return reset;\n }\n\n /** The cards on a board, and how many sit in each phase. */\n async #occupancy(scope: StoredBoardScope, key: string): Promise<{ cards: number; phases: Map<string, number> }> {\n const phases = new Map<string, number>();\n let cards = 0;\n for (const item of await this.deps.workItems.list(scope)) {\n if (boardForWorkItem(item) !== key) continue;\n cards++;\n for (const stage of new Set(item.stages)) phases.set(stage, (phases.get(stage) ?? 0) + 1);\n }\n return { cards, phases };\n }\n\n /** Refuses a change that removes, or changes the kind of, a phase cards sit in. */\n async #checkPhasesFree(\n scope: StoredBoardScope,\n row: StoredBoardRecord,\n next: readonly StoredPhaseInput[],\n ): Promise<void> {\n const kinds = new Map(next.map(phase => [phase.key, phase.kind]));\n const changed = row.phases.filter(phase => kinds.get(phase.key) !== phase.kind).map(phase => phase.key);\n if (changed.length === 0) return;\n const occupancy = (await this.#occupancy(scope, row.key)).phases;\n const inUse = Object.fromEntries(changed.flatMap(key => (occupancy.get(key) ? [[key, occupancy.get(key)!]] : [])));\n if (Object.keys(inUse).length === 0) return;\n throw new BoardWriteError(409, {\n error: 'phase_in_use',\n message: `Cards sit in ${Object.entries(inUse)\n .map(([key, count]) => `\"${key}\" (${count})`)\n .join(', ')}; move them before removing those phases or changing their kind.`,\n phases: inUse,\n });\n }\n\n async #audit(\n scope: StoredBoardScope,\n writer: BoardWriter,\n action: 'created' | 'updated' | 'deleted' | 'reset',\n board: { key: string; name: string },\n ): Promise<void> {\n await writer.audit({\n action: `factory.board.${action}`,\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'board', id: board.key, name: board.name }],\n });\n }\n}\n"],"mappings":";;;;;;;;;AAgDA,IAAa,kBAAb,cAAqC,MAAM;CAG9B;CACA;CAHX,OAAgB;CAChB,YACE,QACA,MACA;EACA,MAAM,KAAK,WAAW,KAAK,KAAK;EAHvB,KAAA,SAAA;EACA,KA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KAAK,IAAI,EAAE;GACd,QAAQ;EACV,CAAC;CACH;CAEA,MAAM,OACJ,OACA,QACA,QACA,OACe;EACf,MAAM,OAAO,MAAM;GACjB,QAAQ,iBAAiB;GACzB,kBAAkB,MAAM;GACxB,SAAS,CAAC;IAAE,MAAM;IAAS,IAAI,MAAM;IAAK,MAAM,MAAM;GAAK,CAAC;EAC9D,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"board-writes.js","names":[],"sources":["../../src/boards/board-writes.ts"],"sourcesContent":["/**\n * Writes to a project's stored boards, shared by the boards API and `MastraFactory#upsertBoard()`.\n *\n * Every write is checked against the rules `defineBoard()` enforces, the skills its runners name,\n * the code behaviour of a code board's copy, and the cards sitting on the board. It then\n * invalidates the project's board cache and records an audit event.\n */\n\nimport type { z } from 'zod';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type { EmitAuditInput } from '../storage/domains/audit/domain.js';\nimport { StoredBoardError } from '../storage/domains/boards/base.js';\nimport type {\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n StoredPhaseInput,\n} from '../storage/domains/boards/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport { codeBoardOf } from './define-board.js';\nimport type { ProjectBoardCache } from './project-boards.js';\nimport { createBoardRegistry } from './registry.js';\nimport { boardForWorkItem } from './semantics.js';\nimport {\n codeBehaviourConflicts,\n compileStoredBoard,\n sameBoardDefinition,\n storedBoardInputSchema,\n} from './stored-board.js';\nimport { workBoard } from './work.js';\n\nexport interface BoardWritesDeps {\n storage: StoredBoardsStorage;\n /** The per-project boards: the code boards and their seeds, skills, and the cache to invalidate. */\n boards: Pick<ProjectBoardCache, 'describe' | 'invalidate' | 'codeRegistry' | 'codeSkills' | 'seedFor'>;\n /** Read to refuse edits that would strand cards. */\n workItems: Pick<WorkItemsStorage, 'list'>;\n}\n\n/** Who writes: stored as the board's author, and the audit event's actor. */\nexport interface BoardWriter {\n id: string;\n audit(input: EmitAuditInput): Promise<void>;\n}\n\n/** A refused board write. `status` and `body` are what the boards API answers with. */\nexport class BoardWriteError extends Error {\n override name = 'BoardWriteError';\n constructor(\n readonly status: 404 | 409 | 422,\n readonly body: { error: string; message?: string } & Record<string, unknown>,\n ) {\n super(body.message ?? body.error);\n }\n\n get code(): string {\n return this.body.error;\n }\n}\n\nexport function issueMessage(issues: readonly z.core.$ZodIssue[]): string {\n return issues\n .map(issue => (issue.path.length > 0 ? `${issue.path.join('.')}: ${issue.message}` : issue.message))\n .join('; ');\n}\n\nconst UNKNOWN_SKILL = 'but no such skill exists';\nconst UPSERT_ATTEMPTS = 3;\n\n/** Storage refusals (a stale revision, a missing or existing board) as board write errors. */\nasync function stored<T>(write: () => Promise<T>): Promise<T> {\n try {\n return await write();\n } catch (error) {\n if (error instanceof StoredBoardError) {\n throw new BoardWriteError(error.code === 'board_not_found' ? 404 : 409, {\n error: error.code,\n message: error.message,\n });\n }\n throw error;\n }\n}\n\n/**\n * The retired Review board's key is never written: a project still using it is served it from\n * code, and a board under its key elsewhere would take over the cards stored there.\n */\nfunction refuseReservedBoard(key: string): void {\n if (key !== LEGACY_REVIEW_BOARD) return;\n throw new BoardWriteError(409, {\n error: 'reserved_board',\n message: `Board \"${key}\" is reserved for the retired Review board.`,\n });\n}\n\nexport class BoardWrites {\n constructor(private readonly deps: BoardWritesDeps) {}\n\n /**\n * Code boards can't be created over, and Work can't be deleted while its code handlers run by its\n * key; the retired Review board's key can't be used at all.\n */\n refuseCodeBoard(key: string, action: 'create' | 'edit' | 'delete'): void {\n refuseReservedBoard(key);\n const { boards } = this.deps;\n const code = boards.codeRegistry.get(key);\n if (!code) return;\n const stored = boards.seedFor(key) !== undefined;\n if (action === 'edit' && stored) return;\n if (action === 'delete' && stored && codeBoardOf(code) !== workBoard) return;\n throw new BoardWriteError(409, {\n error: 'code_board',\n message:\n action === 'delete' && stored\n ? `Board \"${key}\" is defined in code and can't be deleted; reset it to its default instead.`\n : `Board \"${key}\" is defined in code and can't be ${action === 'create' ? 'created over' : 'changed'} here.`,\n });\n }\n\n async existing(scope: StoredBoardScope, key: string): Promise<StoredBoardRecord> {\n const row = await this.deps.storage.get(scope, key);\n if (!row) throw new BoardWriteError(404, { error: 'board_not_found', message: `Board \"${key}\" does not exist.` });\n return row;\n }\n\n /**\n * Validates a definition the way `defineBoard()` does, plus the skills its runners name. A code\n * board's copy is also checked against the code behaviour of its board and phase keys.\n */\n validate(input: unknown): StoredBoardInput {\n const { boards } = this.deps;\n const parsed = storedBoardInputSchema.safeParse(input);\n if (!parsed.success) {\n throw new BoardWriteError(422, { error: 'invalid_board', message: issueMessage(parsed.error.issues) });\n }\n refuseReservedBoard(parsed.data.key);\n const code = boards.seedFor(parsed.data.key) && boards.codeRegistry.get(parsed.data.key);\n if (code) {\n const conflicts = codeBehaviourConflicts(parsed.data, code);\n if (conflicts.length > 0) {\n throw new BoardWriteError(422, { error: 'code_behaviour', message: conflicts.join(' '), conflicts });\n }\n }\n const board = code ? compileStoredBoard(parsed.data, code) : compileStoredBoard(parsed.data);\n const problems = findBoardSkillProblems(\n createBoardRegistry({ boards: [board], includeDefaultBoards: false }),\n boards.codeSkills,\n );\n const unknown = problems.filter(problem => problem.includes(UNKNOWN_SKILL));\n if (unknown.length > 0) throw new BoardWriteError(422, { error: 'unknown_skill', message: unknown.join(' ') });\n return parsed.data;\n }\n\n /** Creates a board under a key no code board uses. */\n async create(scope: StoredBoardScope, input: unknown, writer: BoardWriter): Promise<StoredBoardRecord> {\n const key = (input as { key?: unknown } | null)?.key;\n if (typeof key === 'string') this.refuseCodeBoard(key, 'create');\n const board = this.validate(input);\n const row = await stored(() => this.deps.storage.create(scope, board, writer.id));\n this.deps.boards.invalidate(scope);\n await this.#audit(scope, writer, 'created', board);\n return row;\n }\n\n /**\n * Stores a validated board in a project, after its first load stored Factory's boards: creates\n * it when the project has none under its key, and otherwise replaces the project's board, edited\n * or not, at its current revision, with the same checks as an edit. A write that loses a race\n * with another one rereads and tries again.\n */\n async upsert(\n scope: StoredBoardScope,\n board: StoredBoardInput,\n writer: BoardWriter,\n ): Promise<'inserted' | 'updated' | 'unchanged'> {\n refuseReservedBoard(board.key);\n const { storage, boards } = this.deps;\n await boards.describe(scope);\n for (let attempt = 1; ; attempt++) {\n const row = await storage.get(scope, board.key);\n try {\n if (!row) {\n if (!(await storage.insertIfMissing(scope, board, writer.id))) {\n throw new BoardWriteError(409, {\n error: 'revision_mismatch',\n message: `Board \"${board.key}\" was stored by another write; try again.`,\n });\n }\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'created', board);\n return 'inserted';\n }\n const { key, ...definition } = board;\n const { written } = await this.replace(scope, key, definition, { expectedRevision: row.revision, writer });\n return written ? 'updated' : 'unchanged';\n } catch (error) {\n const lost =\n error instanceof BoardWriteError && (error.code === 'revision_mismatch' || error.code === 'board_not_found');\n if (!lost || attempt >= UPSERT_ATTEMPTS) throw error;\n }\n }\n }\n\n /**\n * Replaces a board's definition at `expectedRevision`. Saving it unchanged writes nothing;\n * `written` says whether anything was stored.\n */\n async replace(\n scope: StoredBoardScope,\n key: string,\n definition: Omit<StoredBoardInput, 'key'>,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<{ row: StoredBoardRecord; written: boolean }> {\n const { storage, boards } = this.deps;\n this.refuseCodeBoard(key, 'edit');\n const seed = boards.seedFor(key);\n // The project's first load stores Factory's boards.\n if (seed) await boards.describe(scope);\n const row = await this.existing(scope, key);\n const input = this.validate({ key, ...definition });\n if (row.revision === expectedRevision && sameBoardDefinition(row, input)) {\n return { row, written: false };\n }\n await this.#checkPhasesFree(scope, row, input.phases);\n const { key: _key, ...replacement } = input;\n const replaced = await stored(() =>\n storage.replace(scope, key, replacement, { expectedRevision, actor: writer.id }),\n );\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'updated', input);\n return { row: replaced, written: true };\n }\n\n /** Deletes a stored board that no card sits on. */\n async remove(\n scope: StoredBoardScope,\n key: string,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<void> {\n this.refuseCodeBoard(key, 'delete');\n // The project's first load stores Factory's boards.\n if (this.deps.boards.seedFor(key)) await this.deps.boards.describe(scope);\n const row = await this.existing(scope, key);\n const { cards } = await this.#occupancy(scope, key);\n if (cards > 0) {\n throw new BoardWriteError(409, {\n error: 'board_in_use',\n message: `Board \"${key}\" still has cards; move or delete them first.`,\n cards,\n });\n }\n await stored(() => this.deps.storage.delete(scope, key, { expectedRevision }));\n this.deps.boards.invalidate(scope);\n await this.#audit(scope, writer, 'deleted', row);\n }\n\n /** Rewrites a board Factory stores to Factory's current definition of it, at the next revision. */\n async reset(\n scope: StoredBoardScope,\n key: string,\n { expectedRevision, writer }: { expectedRevision: number; writer: BoardWriter },\n ): Promise<StoredBoardRecord> {\n const { storage, boards } = this.deps;\n const seed = boards.seedFor(key);\n if (!seed) {\n this.refuseCodeBoard(key, 'edit');\n await this.existing(scope, key);\n throw new BoardWriteError(409, {\n error: 'not_code_board',\n message: `Board \"${key}\" was created in this project and has no default to reset to.`,\n });\n }\n await boards.describe(scope);\n const row = await this.existing(scope, key);\n await this.#checkPhasesFree(scope, row, seed.phases);\n const reset = await stored(() => storage.resetTo(scope, key, seed, { expectedRevision, actor: writer.id }));\n boards.invalidate(scope);\n await this.#audit(scope, writer, 'reset', row);\n return reset;\n }\n\n /** The cards on a board, and how many sit in each phase. */\n async #occupancy(scope: StoredBoardScope, key: string): Promise<{ cards: number; phases: Map<string, number> }> {\n const phases = new Map<string, number>();\n let cards = 0;\n for (const item of await this.deps.workItems.list(scope)) {\n if (boardForWorkItem(item) !== key) continue;\n cards++;\n for (const stage of new Set(item.stages)) phases.set(stage, (phases.get(stage) ?? 0) + 1);\n }\n return { cards, phases };\n }\n\n /** Refuses a change that removes, or changes the kind of, a phase cards sit in. */\n async #checkPhasesFree(\n scope: StoredBoardScope,\n row: StoredBoardRecord,\n next: readonly StoredPhaseInput[],\n ): Promise<void> {\n const kinds = new Map(next.map(phase => [phase.key, phase.kind]));\n const changed = row.phases.filter(phase => kinds.get(phase.key) !== phase.kind).map(phase => phase.key);\n if (changed.length === 0) return;\n const occupancy = (await this.#occupancy(scope, row.key)).phases;\n const inUse = Object.fromEntries(changed.flatMap(key => (occupancy.get(key) ? [[key, occupancy.get(key)!]] : [])));\n if (Object.keys(inUse).length === 0) return;\n throw new BoardWriteError(409, {\n error: 'phase_in_use',\n message: `Cards sit in ${Object.entries(inUse)\n .map(([key, count]) => `\"${key}\" (${count})`)\n .join(', ')}; move them before removing those phases or changing their kind.`,\n phases: inUse,\n });\n }\n\n async #audit(\n scope: StoredBoardScope,\n writer: BoardWriter,\n action: 'created' | 'updated' | 'deleted' | 'reset',\n board: { key: string; name: string },\n ): Promise<void> {\n await writer.audit({\n action: `factory.board.${action}`,\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'board', id: board.key, name: board.name }],\n });\n }\n}\n"],"mappings":";;;;;;;;;;AAiDA,IAAa,kBAAb,cAAqC,MAAM;CAG9B;CACA;CAHX,OAAgB;CAChB,YACE,QACA,MACA;EACA,MAAM,KAAK,WAAW,KAAK,KAAK;EAHvB,KAAA,SAAA;EACA,KAAA,OAAA;CAGX;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,KAAK;CACnB;AACF;AAEA,SAAgB,aAAa,QAA6C;CACxE,OAAO,OACJ,KAAI,UAAU,MAAM,KAAK,SAAS,IAAI,GAAG,MAAM,KAAK,KAAK,GAAG,EAAE,IAAI,MAAM,YAAY,MAAM,OAAQ,CAAC,CACnG,KAAK,IAAI;AACd;AAEA,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;;AAGxB,eAAe,OAAU,OAAqC;CAC5D,IAAI;EACF,OAAO,MAAM,MAAM;CACrB,SAAS,OAAO;EACd,IAAI,iBAAiB,kBACnB,MAAM,IAAI,gBAAgB,MAAM,SAAS,oBAAoB,MAAM,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AK,CAAC;EAC9D,CAAC;CACH;AACF"}
@@ -2,6 +2,6 @@ import type { RuleFacts } from '../rules/rule-group.js';
2
2
  import type { Card } from '../storage/domains/work-items/base.js';
3
3
  /** What a condition (`autoStartWhen`, `exitTool.autoApproveWhen`, an intake route's `when`) can test about a card. */
4
4
  export declare function cardRuleFacts(item: Pick<Card, 'title' | 'metadata' | 'externalSource'> & {
5
- workItem?: Pick<Card['workItem'], 'labels' | 'author'>;
5
+ workItem?: Pick<Card['workItem'], 'labels' | 'author'> & Partial<Pick<Card['workItem'], 'sources'>>;
6
6
  }): RuleFacts;
7
7
  //# sourceMappingURL=card-facts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"card-facts.d.ts","sourceRoot":"","sources":["../../src/boards/card-facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAGlE,sHAAsH;AACtH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,gBAAgB,CAAC,GAAG;IAC1D,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;CACxD,GACA,SAAS,CAsBX"}
1
+ {"version":3,"file":"card-facts.d.ts","sourceRoot":"","sources":["../../src/boards/card-facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAIlE,sHAAsH;AACtH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,gBAAgB,CAAC,GAAG;IAC1D,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;CACrG,GACA,SAAS,CA2BX"}
@@ -1,5 +1,6 @@
1
1
  import { authorTrusted } from "../rules/types.js";
2
2
  import { workItemProviderAdapter } from "../work-items/providers/index.js";
3
+ import { newestOpenPullRequestNumber } from "./semantics.js";
3
4
  // src/boards/card-facts.ts
4
5
  /** What a condition (`autoStartWhen`, `exitTool.autoApproveWhen`, an intake route's `when`) can test about a card. */
5
6
  function cardRuleFacts(item) {
@@ -7,12 +8,15 @@ function cardRuleFacts(item) {
7
8
  const metadata = item.metadata ?? {};
8
9
  const provider = source ? item.workItem ?? workItemProviderAdapter(source).toSource(source, metadata) : null;
9
10
  const labels = source ? provider?.labels ?? [] : Array.isArray(metadata.labels) ? metadata.labels.filter((label) => typeof label === "string") : [];
11
+ const pointer = metadata.openPullRequestNumber;
12
+ const pullRequest = typeof pointer === "number" ? pointer : newestOpenPullRequestNumber({ workItem: item.workItem ?? null });
10
13
  const author = source ? provider?.author ?? null : typeof metadata.author === "string" ? metadata.author : null;
11
14
  return {
12
15
  "item.labels": labels,
13
16
  "item.title": item.title,
14
17
  ...author !== null ? { "item.author": author } : {},
15
18
  "author.trusted": authorTrusted(item.metadata),
19
+ ...pullRequest !== null ? { "item.pullRequest": pullRequest } : {},
16
20
  ...source ? {
17
21
  "source.kind": source.type === "pull-request" ? "pull_request" : source.type,
18
22
  "source.integration": source.integrationId
@@ -1 +1 @@
1
- {"version":3,"file":"card-facts.js","names":[],"sources":["../../src/boards/card-facts.ts"],"sourcesContent":["import type { RuleFacts } from '../rules/rule-group.js';\nimport { authorTrusted } from '../rules/types.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemProviderAdapter } from '../work-items/providers/index.js';\n\n/** What a condition (`autoStartWhen`, `exitTool.autoApproveWhen`, an intake route's `when`) can test about a card. */\nexport function cardRuleFacts(\n item: Pick<Card, 'title' | 'metadata' | 'externalSource'> & {\n workItem?: Pick<Card['workItem'], 'labels' | 'author'>;\n },\n): RuleFacts {\n const source = item.externalSource;\n const metadata = item.metadata ?? {};\n const provider = source ? (item.workItem ?? workItemProviderAdapter(source).toSource(source, metadata)) : null;\n const labels = source\n ? (provider?.labels ?? [])\n : Array.isArray(metadata.labels)\n ? metadata.labels.filter((label): label is string => typeof label === 'string')\n : [];\n const author = source ? (provider?.author ?? null) : typeof metadata.author === 'string' ? metadata.author : null;\n return {\n 'item.labels': labels,\n 'item.title': item.title,\n ...(author !== null ? { 'item.author': author } : {}),\n 'author.trusted': authorTrusted(item.metadata),\n ...(source\n ? {\n 'source.kind': source.type === 'pull-request' ? 'pull_request' : source.type,\n 'source.integration': source.integrationId,\n }\n : {}),\n };\n}\n"],"mappings":";;;;AAMA,SAAgB,cACd,MAGW;CACX,MAAM,SAAS,KAAK;CACpB,MAAM,WAAW,KAAK,YAAY,CAAC;CACnC,MAAM,WAAW,SAAU,KAAK,YAAY,wBAAwB,MAAM,CAAC,CAAC,SAAS,QAAQ,QAAQ,IAAK;CAC1G,MAAM,SAAS,SACV,UAAU,UAAU,CAAC,IACtB,MAAM,QAAQ,SAAS,MAAM,IAC3B,SAAS,OAAO,QAAQ,UAA2B,OAAO,UAAU,QAAQ,IAC5E,CAAC;CACP,MAAM,SAAS,SAAU,UAAU,UAAU,OAAQ,OAAO,SAAS,WAAW,WAAW,SAAS,SAAS;CAC7G,OAAO;EACL,eAAe;EACf,cAAc,KAAK;EACnB,GAAI,WAAW,OAAO,EAAE,eAAe,OAAO,IAAI,CAAC;EACnD,kBAAkB,cAAc,KAAK,QAAQ;EAC7C,GAAI,SACA;GACE,eAAe,OAAO,SAAS,iBAAiB,iBAAiB,OAAO;GACxE,sBAAsB,OAAO;EAC/B,IACA,CAAC;CACP;AACF"}
1
+ {"version":3,"file":"card-facts.js","names":[],"sources":["../../src/boards/card-facts.ts"],"sourcesContent":["import type { RuleFacts } from '../rules/rule-group.js';\nimport { authorTrusted } from '../rules/types.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemProviderAdapter } from '../work-items/providers/index.js';\nimport { newestOpenPullRequestNumber } from './semantics.js';\n\n/** What a condition (`autoStartWhen`, `exitTool.autoApproveWhen`, an intake route's `when`) can test about a card. */\nexport function cardRuleFacts(\n item: Pick<Card, 'title' | 'metadata' | 'externalSource'> & {\n workItem?: Pick<Card['workItem'], 'labels' | 'author'> & Partial<Pick<Card['workItem'], 'sources'>>;\n },\n): RuleFacts {\n const source = item.externalSource;\n const metadata = item.metadata ?? {};\n const provider = source ? (item.workItem ?? workItemProviderAdapter(source).toSource(source, metadata)) : null;\n const labels = source\n ? (provider?.labels ?? [])\n : Array.isArray(metadata.labels)\n ? metadata.labels.filter((label): label is string => typeof label === 'string')\n : [];\n const pointer = metadata.openPullRequestNumber;\n const pullRequest =\n typeof pointer === 'number' ? pointer : newestOpenPullRequestNumber({ workItem: item.workItem ?? null });\n const author = source ? (provider?.author ?? null) : typeof metadata.author === 'string' ? metadata.author : null;\n return {\n 'item.labels': labels,\n 'item.title': item.title,\n ...(author !== null ? { 'item.author': author } : {}),\n 'author.trusted': authorTrusted(item.metadata),\n // The open change request: the one Factory opened for the card, else its own or an attached open one.\n ...(pullRequest !== null ? { 'item.pullRequest': pullRequest } : {}),\n ...(source\n ? {\n 'source.kind': source.type === 'pull-request' ? 'pull_request' : source.type,\n 'source.integration': source.integrationId,\n }\n : {}),\n };\n}\n"],"mappings":";;;;;AAOA,SAAgB,cACd,MAGW;CACX,MAAM,SAAS,KAAK;CACpB,MAAM,WAAW,KAAK,YAAY,CAAC;CACnC,MAAM,WAAW,SAAU,KAAK,YAAY,wBAAwB,MAAM,CAAC,CAAC,SAAS,QAAQ,QAAQ,IAAK;CAC1G,MAAM,SAAS,SACV,UAAU,UAAU,CAAC,IACtB,MAAM,QAAQ,SAAS,MAAM,IAC3B,SAAS,OAAO,QAAQ,UAA2B,OAAO,UAAU,QAAQ,IAC5E,CAAC;CACP,MAAM,UAAU,SAAS;CACzB,MAAM,cACJ,OAAO,YAAY,WAAW,UAAU,4BAA4B,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC;CACzG,MAAM,SAAS,SAAU,UAAU,UAAU,OAAQ,OAAO,SAAS,WAAW,WAAW,SAAS,SAAS;CAC7G,OAAO;EACL,eAAe;EACf,cAAc,KAAK;EACnB,GAAI,WAAW,OAAO,EAAE,eAAe,OAAO,IAAI,CAAC;EACnD,kBAAkB,cAAc,KAAK,QAAQ;EAE7C,GAAI,gBAAgB,OAAO,EAAE,oBAAoB,YAAY,IAAI,CAAC;EAClE,GAAI,SACA;GACE,eAAe,OAAO,SAAS,iBAAiB,iBAAiB,OAAO;GACxE,sBAAsB,OAAO;EAC/B,IACA,CAAC;CACP;AACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Board a card belongs to when nothing names one: rows written before boards were persisted, and
3
+ * cards filed without a route, label route or intake binding. Every project is seeded with it (the
4
+ * Work board); nothing else about it is special.
5
+ */
6
+ export declare const DEFAULT_BOARD_ID = "work";
7
+ //# sourceMappingURL=default-board.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-board.d.ts","sourceRoot":"","sources":["../../src/boards/default-board.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ // src/boards/default-board.ts
2
+ /**
3
+ * Board a card belongs to when nothing names one: rows written before boards were persisted, and
4
+ * cards filed without a route, label route or intake binding. Every project is seeded with it (the
5
+ * Work board); nothing else about it is special.
6
+ */
7
+ const DEFAULT_BOARD_ID = "work";
8
+ export { DEFAULT_BOARD_ID };
9
+
10
+ //# sourceMappingURL=default-board.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-board.js","names":[],"sources":["../../src/boards/default-board.ts"],"sourcesContent":["/**\n * Board a card belongs to when nothing names one: rows written before boards were persisted, and\n * cards filed without a route, label route or intake binding. Every project is seeded with it (the\n * Work board); nothing else about it is special.\n */\nexport const DEFAULT_BOARD_ID = 'work';\n"],"mappings":";;;;;;AAKA,MAAa,mBAAmB"}
@@ -1,8 +1,6 @@
1
1
  import type { RuleFacts, RuleGroup } from '../rules/rule-group.js';
2
- import type { FactoryGithubEventName, FactoryGithubRuleContext, FactoryGitLabEventName, FactoryGitLabRuleContext, FactoryIncidentioEventName, FactoryIncidentioRuleContext, FactoryJiraEventName, FactoryJiraRuleContext, FactoryLinearEventName, FactoryLinearRuleContext, FactoryRuleHandler, FactoryRuleSource, FactoryStageRuleContext, FactoryToolResultRuleContext } from '../rules/types.js';
2
+ import type { FactoryGithubEventName, FactoryGithubRuleContext, FactoryGitLabEventName, FactoryGitLabRuleContext, FactoryIncidentioEventName, FactoryIncidentioRuleContext, FactoryJiraEventName, FactoryJiraRuleContext, FactoryLinearEventName, FactoryLinearRuleContext, FactoryRuleHandler, FactoryToolResultRuleContext } from '../rules/types.js';
3
3
  import type { BoardTransitionPolicy } from './transition-policy.js';
4
- type BoardPhaseHandlers = Partial<Record<FactoryRuleSource, FactoryRuleHandler<FactoryStageRuleContext>>>;
5
- type ReadonlyBoardPhaseHandlers = Readonly<BoardPhaseHandlers>;
6
4
  /** Runs when an agent seated on this board completes the named tool. */
7
5
  export type BoardToolResultRuleHandler = FactoryRuleHandler<FactoryToolResultRuleContext>;
8
6
  export type BoardToolRule = {
@@ -27,10 +25,6 @@ export interface BoardEventRules {
27
25
  readonly incidentio?: BoardEventHandlerMap<FactoryIncidentioEventName, FactoryIncidentioRuleContext>;
28
26
  }
29
27
  export type BoardEventIntegration = keyof BoardEventRules;
30
- type ReadonlyFactoryBoardRules = Readonly<Record<string, Readonly<Partial<Record<FactoryRuleSource, Readonly<{
31
- onEnter?: FactoryRuleHandler<FactoryStageRuleContext>;
32
- onExit?: FactoryRuleHandler<FactoryStageRuleContext>;
33
- }>>>>>>;
34
28
  /**
35
29
  * What a phase means to the runtime.
36
30
  * - `resting`: nobody is seated; a card waits for a person or an event.
@@ -42,11 +36,17 @@ export type BoardPhaseKind = 'resting' | 'working' | 'terminal';
42
36
  export declare const FACTORY_AGENT_ID = "code-agent";
43
37
  /** The session context a working phase runs in when it names none. */
44
38
  export declare const DEFAULT_PHASE_CONTEXT = "work";
39
+ /**
40
+ * Seat review runs sit in. Review skills load only in it, it is the only seat granted the verdict
41
+ * tool, and its sessions check out code the author wrote, so they never trust that checkout's
42
+ * instruction files. A runner context, not a phase key: any board's phases may run in it.
43
+ */
44
+ export declare const REVIEW_CONTEXT = "review";
45
45
  /** Who runs a working phase, and with what. */
46
46
  export interface BoardPhaseRunner {
47
47
  /** Must be `code-agent`, the agent Factory runs; omitted means that agent. */
48
48
  readonly agentId?: string;
49
- /** Skill started when a card enters the phase from a source with no `onEnter` handler. */
49
+ /** Skill started when a card enters the phase. Without one, entering the phase starts no run. */
50
50
  readonly skill?: string;
51
51
  /**
52
52
  * The session the phase runs in. Phases naming the same context share one session per card;
@@ -55,6 +55,18 @@ export interface BoardPhaseRunner {
55
55
  readonly context?: string;
56
56
  /** Appended to every run the phase starts. */
57
57
  readonly instructions?: string;
58
+ /**
59
+ * Pursue the phase's work as a goal: the run's thread holds `objective` and the agent's goal
60
+ * judge keeps it working until the objective is met. The judge sees only this text and the
61
+ * latest messages, so it must say when the work is done.
62
+ */
63
+ readonly goal?: BoardPhaseGoal;
64
+ }
65
+ /** The objective a phase's runs pursue, judged in-loop until met. */
66
+ export interface BoardPhaseGoal {
67
+ readonly objective: string;
68
+ /** Judged turns before the goal pauses for a person; defaults to the agent's setting. */
69
+ readonly maxRuns?: number;
58
70
  }
59
71
  /**
60
72
  * The tool whose successful call ends a working phase. The agent then moves the card itself with
@@ -70,6 +82,9 @@ export interface BoardPhaseExitTool {
70
82
  /** With `autoApprove`, only cards this matches are approved without a person. */
71
83
  readonly autoApproveWhen?: RuleGroup;
72
84
  }
85
+ /** Factory tools a working phase grants the session that works the card there. */
86
+ export declare const FACTORY_PHASE_TOOLS: readonly ['factory_record_review_verdict', 'factory_review_source'];
87
+ export type FactoryPhaseTool = (typeof FACTORY_PHASE_TOOLS)[number];
73
88
  type BoardPhaseBase<PhaseId extends string> = {
74
89
  readonly name?: string;
75
90
  /** @deprecated Use `name`. */
@@ -79,10 +94,12 @@ type BoardPhaseBase<PhaseId extends string> = {
79
94
  readonly nextPhases?: readonly PhaseId[];
80
95
  /** @deprecated List the phase in `nextPhases`. */
81
96
  readonly next?: PhaseId;
82
- /** Named moves rules can choose by outcome; each target is also an allowed next phase. */
97
+ /** @deprecated Ignored apart from its targets, which are allowed next phases; list them in `nextPhases`. */
83
98
  readonly outcomes?: Readonly<Record<string, PhaseId>>;
84
- readonly onEnter?: ReadonlyBoardPhaseHandlers;
85
- readonly onExit?: ReadonlyBoardPhaseHandlers;
99
+ /** @deprecated Ignored; a phase starts its run from `runner.skill`. */
100
+ readonly onEnter?: Readonly<Record<string, unknown>>;
101
+ /** @deprecated Ignored; a phase starts its run from `runner.skill`. */
102
+ readonly onExit?: Readonly<Record<string, unknown>>;
86
103
  };
87
104
  type WorkingPhaseFields = {
88
105
  readonly runner?: BoardPhaseRunner;
@@ -94,6 +111,12 @@ type WorkingPhaseFields = {
94
111
  readonly autoStartWhen?: RuleGroup;
95
112
  /** A bare tool name is shorthand for `{ id }`, with nothing approved on a person's behalf. */
96
113
  readonly exitTool?: string | BoardPhaseExitTool;
114
+ /**
115
+ * Factory tools the session working the card here gets, on top of the move tool. Only the
116
+ * session whose context is the phase's `runner.context` gets them, and only while the card
117
+ * is in this phase.
118
+ */
119
+ readonly tools?: readonly FactoryPhaseTool[];
97
120
  };
98
121
  type NonWorkingPhaseFields = {
99
122
  readonly runner?: never;
@@ -101,6 +124,7 @@ type NonWorkingPhaseFields = {
101
124
  readonly autoStart?: never;
102
125
  readonly autoStartWhen?: never;
103
126
  readonly exitTool?: never;
127
+ readonly tools?: never;
104
128
  };
105
129
  /** A phase as a board declares it. */
106
130
  export type BoardPhaseDefinition<PhaseId extends string> = (BoardPhaseBase<PhaseId> & NonWorkingPhaseFields & {
@@ -115,13 +139,10 @@ type ResolvedPhaseBase<PhaseId extends string> = {
115
139
  /** @deprecated Use `name`; kept equal to it for code written against older Factory versions. */
116
140
  readonly title: string;
117
141
  readonly description?: string;
118
- /** Every phase a card may move to from here, including outcome targets. */
142
+ /** Every phase a card may move to from here. */
119
143
  readonly nextPhases: readonly PhaseId[];
120
144
  /** @deprecated Use `nextPhases`; set when the phase declared `next`. */
121
145
  readonly next?: PhaseId;
122
- readonly outcomes?: Readonly<Record<string, PhaseId>>;
123
- readonly onEnter?: ReadonlyBoardPhaseHandlers;
124
- readonly onExit?: ReadonlyBoardPhaseHandlers;
125
146
  };
126
147
  /**
127
148
  * A phase as the board resolved it: deprecated fields are replaced by their new names, so
@@ -144,11 +165,13 @@ export type BoardPhase<PhaseId extends string> = (ResolvedPhaseBase<PhaseId> & {
144
165
  autoApprove: boolean;
145
166
  autoApproveWhen?: RuleGroup;
146
167
  }>;
168
+ readonly tools?: readonly FactoryPhaseTool[];
147
169
  }) | (ResolvedPhaseBase<PhaseId> & {
148
170
  readonly kind: 'terminal';
149
171
  });
150
172
  export interface BoardTransition<PhaseId extends string> {
151
- readonly outcome: string | null;
173
+ /** Always null: boards no longer name their moves. */
174
+ readonly outcome: null;
152
175
  readonly to: PhaseId;
153
176
  }
154
177
  /**
@@ -168,7 +191,6 @@ export interface BoardDefinition<BoardId extends string, PhaseId extends string>
168
191
  readonly initialPhase: PhaseId;
169
192
  readonly phases: Readonly<Record<PhaseId, BoardPhase<PhaseId>>>;
170
193
  readonly transitions: Readonly<Record<PhaseId, readonly BoardTransition<PhaseId>[]>>;
171
- readonly rules: ReadonlyFactoryBoardRules;
172
194
  /** Tool-result rules keyed by tool name; empty when the board declares none. */
173
195
  readonly tools: BoardToolRules;
174
196
  /** Integration event handlers for cards on this board; empty when the board declares none. */
@@ -1 +1 @@
1
- {"version":3,"file":"define-board.d.ts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