@mastra/factory 0.29.0-alpha.3 → 0.29.0-alpha.5

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 +123 -64
  2. package/dist/boards/board-events.d.ts +89 -9
  3. package/dist/boards/board-events.d.ts.map +1 -1
  4. package/dist/boards/board-events.js +176 -13
  5. package/dist/boards/board-events.js.map +1 -1
  6. package/dist/boards/board-writes.d.ts.map +1 -1
  7. package/dist/boards/board-writes.js +14 -1
  8. package/dist/boards/board-writes.js.map +1 -1
  9. package/dist/boards/busy-card.d.ts +11 -0
  10. package/dist/boards/busy-card.d.ts.map +1 -0
  11. package/dist/boards/busy-card.js +15 -0
  12. package/dist/boards/busy-card.js.map +1 -0
  13. package/dist/boards/card-facts.d.ts.map +1 -1
  14. package/dist/boards/card-facts.js +18 -4
  15. package/dist/boards/card-facts.js.map +1 -1
  16. package/dist/boards/index.d.ts +2 -1
  17. package/dist/boards/index.d.ts.map +1 -1
  18. package/dist/boards/index.js +3 -2
  19. package/dist/boards/intake-dry-run.d.ts +109 -0
  20. package/dist/boards/intake-dry-run.d.ts.map +1 -0
  21. package/dist/boards/intake-dry-run.js +158 -0
  22. package/dist/boards/intake-dry-run.js.map +1 -0
  23. package/dist/boards/intake-lookup.d.ts +32 -0
  24. package/dist/boards/intake-lookup.d.ts.map +1 -0
  25. package/dist/boards/intake-lookup.js +12 -0
  26. package/dist/boards/intake-lookup.js.map +1 -0
  27. package/dist/boards/intake-order.d.ts +32 -0
  28. package/dist/boards/intake-order.d.ts.map +1 -0
  29. package/dist/boards/intake-order.js +60 -0
  30. package/dist/boards/intake-order.js.map +1 -0
  31. package/dist/boards/intake-routing.d.ts +246 -35
  32. package/dist/boards/intake-routing.d.ts.map +1 -1
  33. package/dist/boards/intake-routing.js +437 -52
  34. package/dist/boards/intake-routing.js.map +1 -1
  35. package/dist/boards/reroute.d.ts +7 -3
  36. package/dist/boards/reroute.d.ts.map +1 -1
  37. package/dist/boards/reroute.js +21 -4
  38. package/dist/boards/reroute.js.map +1 -1
  39. package/dist/boards/semantics.d.ts +8 -28
  40. package/dist/boards/semantics.d.ts.map +1 -1
  41. package/dist/boards/semantics.js +7 -39
  42. package/dist/boards/semantics.js.map +1 -1
  43. package/dist/boards/work-routes.d.ts +31 -11
  44. package/dist/boards/work-routes.d.ts.map +1 -1
  45. package/dist/boards/work-routes.js +104 -20
  46. package/dist/boards/work-routes.js.map +1 -1
  47. package/dist/factory.d.ts +27 -1
  48. package/dist/factory.d.ts.map +1 -1
  49. package/dist/factory.js +32 -18
  50. package/dist/factory.js.map +1 -1
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +1 -2
  54. package/dist/integrations/base.d.ts +9 -0
  55. package/dist/integrations/base.d.ts.map +1 -1
  56. package/dist/integrations/dependabot/rules.d.ts.map +1 -1
  57. package/dist/integrations/dependabot/rules.js +2 -6
  58. package/dist/integrations/dependabot/rules.js.map +1 -1
  59. package/dist/integrations/github/commits.d.ts +0 -21
  60. package/dist/integrations/github/commits.d.ts.map +1 -1
  61. package/dist/integrations/github/commits.js +1 -24
  62. package/dist/integrations/github/commits.js.map +1 -1
  63. package/dist/integrations/github/default-rules.d.ts +22 -1
  64. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  65. package/dist/integrations/github/default-rules.js +23 -5
  66. package/dist/integrations/github/default-rules.js.map +1 -1
  67. package/dist/integrations/github/intake-lookup.d.ts +16 -0
  68. package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
  69. package/dist/integrations/github/intake-lookup.js +76 -0
  70. package/dist/integrations/github/intake-lookup.js.map +1 -0
  71. package/dist/integrations/github/integration.d.ts +20 -6
  72. package/dist/integrations/github/integration.d.ts.map +1 -1
  73. package/dist/integrations/github/integration.js +23 -12
  74. package/dist/integrations/github/integration.js.map +1 -1
  75. package/dist/integrations/github/review-status-reporter.js +1 -1
  76. package/dist/integrations/github/routes.d.ts +1 -11
  77. package/dist/integrations/github/routes.d.ts.map +1 -1
  78. package/dist/integrations/github/routes.js +20 -517
  79. package/dist/integrations/github/routes.js.map +1 -1
  80. package/dist/integrations/github/rules.d.ts +12 -1
  81. package/dist/integrations/github/rules.d.ts.map +1 -1
  82. package/dist/integrations/github/rules.js +275 -38
  83. package/dist/integrations/github/rules.js.map +1 -1
  84. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  85. package/dist/integrations/github/sandbox.js +30 -4
  86. package/dist/integrations/github/sandbox.js.map +1 -1
  87. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  88. package/dist/integrations/gitlab/default-rules.js +19 -3
  89. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  90. package/dist/integrations/gitlab/discovery.d.ts +1 -1
  91. package/dist/integrations/gitlab/discovery.js +1 -1
  92. package/dist/integrations/gitlab/discovery.js.map +1 -1
  93. package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
  94. package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
  95. package/dist/integrations/gitlab/intake-lookup.js +85 -0
  96. package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
  97. package/dist/integrations/gitlab/integration.d.ts +5 -0
  98. package/dist/integrations/gitlab/integration.d.ts.map +1 -1
  99. package/dist/integrations/gitlab/integration.js +21 -2
  100. package/dist/integrations/gitlab/integration.js.map +1 -1
  101. package/dist/integrations/gitlab/routes.d.ts +0 -2
  102. package/dist/integrations/gitlab/routes.d.ts.map +1 -1
  103. package/dist/integrations/gitlab/routes.js +49 -165
  104. package/dist/integrations/gitlab/routes.js.map +1 -1
  105. package/dist/integrations/gitlab/rules.d.ts +20 -0
  106. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  107. package/dist/integrations/gitlab/rules.js +128 -19
  108. package/dist/integrations/gitlab/rules.js.map +1 -1
  109. package/dist/integrations/incidentio/routes.d.ts +5 -5
  110. package/dist/integrations/incidentio/routes.d.ts.map +1 -1
  111. package/dist/integrations/incidentio/routes.js +3 -59
  112. package/dist/integrations/incidentio/routes.js.map +1 -1
  113. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  114. package/dist/integrations/incidentio/rules.js +15 -9
  115. package/dist/integrations/incidentio/rules.js.map +1 -1
  116. package/dist/integrations/jira/issue-reconciler.d.ts +1 -1
  117. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
  118. package/dist/integrations/jira/issue-reconciler.js.map +1 -1
  119. package/dist/integrations/jira/routes.d.ts +2 -2
  120. package/dist/integrations/jira/routes.d.ts.map +1 -1
  121. package/dist/integrations/jira/routes.js +0 -68
  122. package/dist/integrations/jira/routes.js.map +1 -1
  123. package/dist/integrations/jira/rules.d.ts.map +1 -1
  124. package/dist/integrations/jira/rules.js +13 -7
  125. package/dist/integrations/jira/rules.js.map +1 -1
  126. package/dist/integrations/linear/routes.d.ts +2 -2
  127. package/dist/integrations/linear/routes.d.ts.map +1 -1
  128. package/dist/integrations/linear/routes.js +0 -83
  129. package/dist/integrations/linear/routes.js.map +1 -1
  130. package/dist/integrations/linear/rules.d.ts.map +1 -1
  131. package/dist/integrations/linear/rules.js +14 -7
  132. package/dist/integrations/linear/rules.js.map +1 -1
  133. package/dist/integrations/platform/github/event-worker.js +9 -1
  134. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  135. package/dist/integrations/platform/github/integration.d.ts +6 -6
  136. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  137. package/dist/integrations/platform/github/integration.js +23 -6
  138. package/dist/integrations/platform/github/integration.js.map +1 -1
  139. package/dist/integrations/platform/jira/routes.d.ts +2 -2
  140. package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
  141. package/dist/integrations/platform/jira/routes.js +0 -69
  142. package/dist/integrations/platform/jira/routes.js.map +1 -1
  143. package/dist/integrations/pull-request-head.d.ts +1 -1
  144. package/dist/integrations/pull-request-head.d.ts.map +1 -1
  145. package/dist/integrations/pull-request-head.js +5 -0
  146. package/dist/integrations/pull-request-head.js.map +1 -1
  147. package/dist/integrations/vanta/rules.d.ts.map +1 -1
  148. package/dist/integrations/vanta/rules.js +2 -6
  149. package/dist/integrations/vanta/rules.js.map +1 -1
  150. package/dist/packages/_internals/workspace/dist/index.js.map +1 -1
  151. package/dist/routes/automation-runs.d.ts +0 -2
  152. package/dist/routes/automation-runs.d.ts.map +1 -1
  153. package/dist/routes/automation-runs.js +2 -6
  154. package/dist/routes/automation-runs.js.map +1 -1
  155. package/dist/routes/board-snapshot.d.ts +8 -1
  156. package/dist/routes/board-snapshot.d.ts.map +1 -1
  157. package/dist/routes/board-snapshot.js +33 -7
  158. package/dist/routes/board-snapshot.js.map +1 -1
  159. package/dist/routes/boards.js.map +1 -1
  160. package/dist/routes/config.d.ts +6 -0
  161. package/dist/routes/config.d.ts.map +1 -1
  162. package/dist/routes/config.js +5 -2
  163. package/dist/routes/config.js.map +1 -1
  164. package/dist/routes/contracts.d.ts +1258 -5
  165. package/dist/routes/contracts.d.ts.map +1 -1
  166. package/dist/routes/contracts.js +588 -17
  167. package/dist/routes/contracts.js.map +1 -1
  168. package/dist/routes/fs.d.ts +10 -0
  169. package/dist/routes/fs.d.ts.map +1 -1
  170. package/dist/routes/fs.js +184 -11
  171. package/dist/routes/fs.js.map +1 -1
  172. package/dist/routes/intake-check.d.ts +92 -0
  173. package/dist/routes/intake-check.d.ts.map +1 -0
  174. package/dist/routes/intake-check.js +322 -0
  175. package/dist/routes/intake-check.js.map +1 -0
  176. package/dist/routes/intake-routes.d.ts +10 -2
  177. package/dist/routes/intake-routes.d.ts.map +1 -1
  178. package/dist/routes/intake-routes.js +292 -11
  179. package/dist/routes/intake-routes.js.map +1 -1
  180. package/dist/routes/mastra-gateway.d.ts.map +1 -1
  181. package/dist/routes/mastra-gateway.js +3 -2
  182. package/dist/routes/mastra-gateway.js.map +1 -1
  183. package/dist/routes/project-sessions.d.ts +49 -0
  184. package/dist/routes/project-sessions.d.ts.map +1 -0
  185. package/dist/routes/project-sessions.js +93 -0
  186. package/dist/routes/project-sessions.js.map +1 -0
  187. package/dist/routes/projects.d.ts.map +1 -1
  188. package/dist/routes/projects.js +4 -17
  189. package/dist/routes/projects.js.map +1 -1
  190. package/dist/routes/run-queue.d.ts +6 -6
  191. package/dist/routes/run-queue.d.ts.map +1 -1
  192. package/dist/routes/run-queue.js +28 -8
  193. package/dist/routes/run-queue.js.map +1 -1
  194. package/dist/routes/session-rows.d.ts +30 -0
  195. package/dist/routes/session-rows.d.ts.map +1 -0
  196. package/dist/routes/session-rows.js +98 -0
  197. package/dist/routes/session-rows.js.map +1 -0
  198. package/dist/routes/source-control-sessions.d.ts +4 -8
  199. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  200. package/dist/routes/source-control-sessions.js +8 -106
  201. package/dist/routes/source-control-sessions.js.map +1 -1
  202. package/dist/routes/surface.d.ts +13 -3
  203. package/dist/routes/surface.d.ts.map +1 -1
  204. package/dist/routes/surface.js +25 -38
  205. package/dist/routes/surface.js.map +1 -1
  206. package/dist/routes/work-item-starters.d.ts +1 -0
  207. package/dist/routes/work-item-starters.d.ts.map +1 -1
  208. package/dist/routes/work-item-starters.js +14 -2
  209. package/dist/routes/work-item-starters.js.map +1 -1
  210. package/dist/routes/work-items.d.ts +13 -0
  211. package/dist/routes/work-items.d.ts.map +1 -1
  212. package/dist/routes/work-items.js +87 -34
  213. package/dist/routes/work-items.js.map +1 -1
  214. package/dist/rules/dispatch-errors.js +1 -1
  215. package/dist/rules/dispatch-errors.js.map +1 -1
  216. package/dist/rules/dispatcher.d.ts +39 -7
  217. package/dist/rules/dispatcher.d.ts.map +1 -1
  218. package/dist/rules/dispatcher.js +362 -127
  219. package/dist/rules/dispatcher.js.map +1 -1
  220. package/dist/rules/event-rules.d.ts +69 -1
  221. package/dist/rules/event-rules.d.ts.map +1 -1
  222. package/dist/rules/event-rules.js +151 -5
  223. package/dist/rules/event-rules.js.map +1 -1
  224. package/dist/rules/processor.d.ts.map +1 -1
  225. package/dist/rules/processor.js +1 -6
  226. package/dist/rules/processor.js.map +1 -1
  227. package/dist/rules/review-source-tool.js +1 -1
  228. package/dist/rules/rule-group.d.ts +18 -1
  229. package/dist/rules/rule-group.d.ts.map +1 -1
  230. package/dist/rules/rule-group.js +52 -8
  231. package/dist/rules/rule-group.js.map +1 -1
  232. package/dist/rules/run-bearing.d.ts +8 -0
  233. package/dist/rules/run-bearing.d.ts.map +1 -0
  234. package/dist/rules/run-bearing.js +11 -0
  235. package/dist/rules/run-bearing.js.map +1 -0
  236. package/dist/rules/start-coordinator.d.ts +2 -3
  237. package/dist/rules/start-coordinator.d.ts.map +1 -1
  238. package/dist/rules/start-coordinator.js +27 -35
  239. package/dist/rules/start-coordinator.js.map +1 -1
  240. package/dist/rules/tools.js +2 -1
  241. package/dist/rules/tools.js.map +1 -1
  242. package/dist/rules/transition-service.d.ts +16 -0
  243. package/dist/rules/transition-service.d.ts.map +1 -1
  244. package/dist/rules/transition-service.js +34 -12
  245. package/dist/rules/transition-service.js.map +1 -1
  246. package/dist/rules/types.d.ts +18 -5
  247. package/dist/rules/types.d.ts.map +1 -1
  248. package/dist/rules/types.js +2 -1
  249. package/dist/rules/types.js.map +1 -1
  250. package/dist/rules/update-fold.d.ts +32 -0
  251. package/dist/rules/update-fold.d.ts.map +1 -0
  252. package/dist/rules/update-fold.js +60 -0
  253. package/dist/rules/update-fold.js.map +1 -0
  254. package/dist/rules/validation.d.ts.map +1 -1
  255. package/dist/rules/validation.js +54 -6
  256. package/dist/rules/validation.js.map +1 -1
  257. package/dist/session/resource-migration.d.ts.map +1 -1
  258. package/dist/session/resource-migration.js +2 -3
  259. package/dist/session/resource-migration.js.map +1 -1
  260. package/dist/session/run-audit.d.ts +9 -0
  261. package/dist/session/run-audit.d.ts.map +1 -1
  262. package/dist/session/run-audit.js +9 -1
  263. package/dist/session/run-audit.js.map +1 -1
  264. package/dist/session/self-review-gate.d.ts +26 -2
  265. package/dist/session/self-review-gate.d.ts.map +1 -1
  266. package/dist/session/self-review-gate.js +60 -10
  267. package/dist/session/self-review-gate.js.map +1 -1
  268. package/dist/session/session-row-query.d.ts +25 -0
  269. package/dist/session/session-row-query.d.ts.map +1 -0
  270. package/dist/session/session-row-query.js +47 -0
  271. package/dist/session/session-row-query.js.map +1 -0
  272. package/dist/session/session-row-status.d.ts +16 -0
  273. package/dist/session/session-row-status.d.ts.map +1 -0
  274. package/dist/session/session-row-status.js +14 -0
  275. package/dist/session/session-row-status.js.map +1 -0
  276. package/dist/session/session-row-view.d.ts +14 -0
  277. package/dist/session/session-row-view.d.ts.map +1 -0
  278. package/dist/session/session-row-view.js +125 -0
  279. package/dist/session/session-row-view.js.map +1 -0
  280. package/dist/session/session-rows.d.ts +46 -0
  281. package/dist/session/session-rows.d.ts.map +1 -0
  282. package/dist/session/session-rows.js +232 -0
  283. package/dist/session/session-rows.js.map +1 -0
  284. package/dist/session/session-threads.d.ts.map +1 -1
  285. package/dist/session/session-threads.js +1 -0
  286. package/dist/session/session-threads.js.map +1 -1
  287. package/dist/session/source-control-tools.d.ts +14 -7
  288. package/dist/session/source-control-tools.d.ts.map +1 -1
  289. package/dist/session/source-control-tools.js +10 -2
  290. package/dist/session/source-control-tools.js.map +1 -1
  291. package/dist/session/work-item-repository.d.ts +44 -0
  292. package/dist/session/work-item-repository.d.ts.map +1 -1
  293. package/dist/session/work-item-repository.js +80 -1
  294. package/dist/session/work-item-repository.js.map +1 -1
  295. package/dist/session/work-item-state-processor.d.ts.map +1 -1
  296. package/dist/session/work-item-state-processor.js +44 -8
  297. package/dist/session/work-item-state-processor.js.map +1 -1
  298. package/dist/storage/domains/audit/actions.d.ts +2 -1
  299. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  300. package/dist/storage/domains/audit/actions.js +3 -1
  301. package/dist/storage/domains/audit/actions.js.map +1 -1
  302. package/dist/storage/domains/boards/base.d.ts +162 -14
  303. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  304. package/dist/storage/domains/boards/base.js +415 -41
  305. package/dist/storage/domains/boards/base.js.map +1 -1
  306. package/dist/storage/domains/boards/schemas.d.ts +6 -0
  307. package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
  308. package/dist/storage/domains/boards/schemas.js +93 -3
  309. package/dist/storage/domains/boards/schemas.js.map +1 -1
  310. package/dist/storage/domains/intake/base.d.ts +11 -10
  311. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  312. package/dist/storage/domains/intake/base.js +30 -65
  313. package/dist/storage/domains/intake/base.js.map +1 -1
  314. package/dist/storage/domains/integrations/base.d.ts +0 -2
  315. package/dist/storage/domains/integrations/base.d.ts.map +1 -1
  316. package/dist/storage/domains/integrations/base.js +0 -6
  317. package/dist/storage/domains/integrations/base.js.map +1 -1
  318. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  319. package/dist/storage/domains/projects/base.js +19 -22
  320. package/dist/storage/domains/projects/base.js.map +1 -1
  321. package/dist/storage/domains/source-control/base.d.ts +0 -10
  322. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  323. package/dist/storage/domains/source-control/base.js +6 -21
  324. package/dist/storage/domains/source-control/base.js.map +1 -1
  325. package/dist/storage/domains/source-control/inmemory.d.ts +1 -1
  326. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  327. package/dist/storage/domains/source-control/inmemory.js +1 -6
  328. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  329. package/dist/storage/domains/work-items/base.d.ts +49 -53
  330. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  331. package/dist/storage/domains/work-items/base.js +152 -156
  332. package/dist/storage/domains/work-items/base.js.map +1 -1
  333. package/dist/storage/domains/work-items/cards.d.ts +3 -2
  334. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  335. package/dist/storage/domains/work-items/cards.js +4 -2
  336. package/dist/storage/domains/work-items/cards.js.map +1 -1
  337. package/dist/storage/domains/work-items/work-item-schema.d.ts +12 -3
  338. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  339. package/dist/storage/domains/work-items/work-item-schema.js +12 -3
  340. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  341. package/dist/storage/legacy-collections.d.ts +9 -0
  342. package/dist/storage/legacy-collections.d.ts.map +1 -0
  343. package/dist/storage/legacy-collections.js +17 -0
  344. package/dist/storage/legacy-collections.js.map +1 -0
  345. package/dist/storage/probed-list.d.ts +11 -0
  346. package/dist/storage/probed-list.d.ts.map +1 -0
  347. package/dist/storage/probed-list.js +52 -0
  348. package/dist/storage/probed-list.js.map +1 -0
  349. package/dist/tools/audit-events-tool.d.ts +2 -2
  350. package/dist/tools/read-tools.d.ts +0 -3
  351. package/dist/tools/read-tools.d.ts.map +1 -1
  352. package/dist/tools/read-tools.js +4 -42
  353. package/dist/tools/read-tools.js.map +1 -1
  354. package/dist/tools/session-tools.d.ts.map +1 -1
  355. package/dist/tools/session-tools.js +5 -9
  356. package/dist/tools/session-tools.js.map +1 -1
  357. package/dist/tools/work-item-tools.d.ts +3 -0
  358. package/dist/tools/work-item-tools.d.ts.map +1 -1
  359. package/dist/tools/work-item-tools.js +8 -4
  360. package/dist/tools/work-item-tools.js.map +1 -1
  361. package/dist/work-item-branch.d.ts +4 -0
  362. package/dist/work-item-branch.d.ts.map +1 -1
  363. package/dist/work-item-branch.js +7 -1
  364. package/dist/work-item-branch.js.map +1 -1
  365. package/dist/work-items/card-context-sessions.d.ts +50 -0
  366. package/dist/work-items/card-context-sessions.d.ts.map +1 -0
  367. package/dist/work-items/card-context-sessions.js +84 -0
  368. package/dist/work-items/card-context-sessions.js.map +1 -0
  369. package/dist/work-items/change-requests.d.ts +87 -0
  370. package/dist/work-items/change-requests.d.ts.map +1 -0
  371. package/dist/work-items/change-requests.js +134 -0
  372. package/dist/work-items/change-requests.js.map +1 -0
  373. package/dist/work-items/create-work-item.d.ts +7 -2
  374. package/dist/work-items/create-work-item.d.ts.map +1 -1
  375. package/dist/work-items/create-work-item.js +44 -13
  376. package/dist/work-items/create-work-item.js.map +1 -1
  377. package/dist/work-items/list-related-cards.d.ts.map +1 -1
  378. package/dist/work-items/list-related-cards.js +1 -1
  379. package/dist/work-items/list-related-cards.js.map +1 -1
  380. package/dist/work-items/providers/github.d.ts.map +1 -1
  381. package/dist/work-items/providers/github.js +1 -0
  382. package/dist/work-items/providers/github.js.map +1 -1
  383. package/dist/workspace.d.ts.map +1 -1
  384. package/dist/workspace.js +1 -3
  385. package/dist/workspace.js.map +1 -1
  386. package/factory-skills/configure-factory-rules/SKILL.md +2 -2
  387. package/factory-skills/factory-build/SKILL.md +1 -1
  388. package/factory-skills/factory-plan/SKILL.md +5 -3
  389. package/factory-skills/factory-self-review/SKILL.md +2 -0
  390. package/factory-skills/factory-triage/SKILL.md +1 -1
  391. package/package.json +10 -10
  392. package/dist/session/filesystem-capture.d.ts +0 -50
  393. package/dist/session/filesystem-capture.d.ts.map +0 -1
  394. package/dist/session/filesystem-capture.js +0 -229
  395. package/dist/session/filesystem-capture.js.map +0 -1
  396. package/dist/storage/domains/filesystem/base.d.ts +0 -30
  397. package/dist/storage/domains/filesystem/base.d.ts.map +0 -1
  398. package/dist/storage/domains/filesystem/base.js +0 -78
  399. package/dist/storage/domains/filesystem/base.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"intake-routing.js","names":[],"sources":["../../src/boards/intake-routing.ts"],"sourcesContent":["import { evaluateRuleGroup } from '../rules/rule-group.js';\nimport type { RuleFacts } from '../rules/rule-group.js';\nimport type { StoredBoardsStorage, StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport type { BoardEventFacts } from './board-events.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { boardFlow, boardForWorkItem, hasPullRequest } from './semantics.js';\n\n/** Reads a project's intake routes, in order. */\nexport type IntakeRoutesReader = Pick<StoredBoardsStorage, 'listIntakeRoutes'>;\n\ntype IntakeRoute = Pick<StoredIntakeRouteRecord, 'id' | 'enabled' | 'when' | 'target' | 'on'>;\n\n/** Whether the route places new cards, rather than only moving existing ones on later events. */\nexport function placesNewCards(route: Pick<StoredIntakeRouteRecord, 'on'>): boolean {\n return route.on.includes('work_item.created');\n}\n\n/**\n * Card metadata naming the intake route that placed the card. Label changes, rebinding its\n * source and replayed arrivals leave such a card where the route put it.\n */\nexport const INTAKE_ROUTE_METADATA_KEY = 'intakeRouteId';\n\n/** Whether an intake route chose this card's board when it arrived. */\nexport function placedByIntakeRoute(item: Pick<Card, 'metadata'>): boolean {\n return typeof item.metadata?.[INTAKE_ROUTE_METADATA_KEY] === 'string';\n}\n\nexport type IntakeTargetProblem = {\n code: 'unknown_board' | 'unknown_phase' | 'terminal_phase' | 'unreachable_phase' | 'join_on_event';\n message: string;\n};\n\n/**\n * Why a route's target can't take cards in this project, or undefined when it can. A route that\n * places new cards needs a phase they can reach; one that only moves existing cards on later\n * events, such as a close, may name any phase, terminal ones included.\n */\nexport function intakeTargetProblem(\n registry: BoardRegistry,\n route: { target: { boardKey: string; phaseKey?: string | null; joinClosedIssue?: boolean }; on: readonly string[] },\n): IntakeTargetProblem | undefined {\n const { target } = route;\n const board = registry.get(target.boardKey);\n if (!board) {\n return { code: 'unknown_board', message: `Board \"${target.boardKey}\" is not installed in this project.` };\n }\n if (target.joinClosedIssue && route.on.some(event => event !== 'work_item.created')) {\n return {\n code: 'join_on_event',\n message:\n 'A route that joins a pull request to the card of the issue it closes handles only arrivals: its `on` must be `work_item.created` alone.',\n };\n }\n if (!target.phaseKey) return undefined;\n if (target.joinClosedIssue && board.phaseKind(target.phaseKey) === 'terminal') {\n return {\n code: 'terminal_phase',\n message: `Phase \"${target.phaseKey}\" on board \"${target.boardKey}\" is terminal; a card a pull request joins can't move there.`,\n };\n }\n if (target.joinClosedIssue) {\n return board.phaseKind(target.phaseKey)\n ? undefined\n : { code: 'unknown_phase', message: `Board \"${target.boardKey}\" has no phase \"${target.phaseKey}\".` };\n }\n const kind = board.phaseKind(target.phaseKey);\n if (!kind) {\n return { code: 'unknown_phase', message: `Board \"${target.boardKey}\" has no phase \"${target.phaseKey}\".` };\n }\n if (!route.on.includes('work_item.created')) return undefined;\n if (kind === 'terminal') {\n return {\n code: 'terminal_phase',\n message: `Phase \"${target.phaseKey}\" on board \"${target.boardKey}\" is terminal; new cards can't land there.`,\n };\n }\n if (!board.allowsTransition(board.initialPhase, target.phaseKey)) {\n return {\n code: 'unreachable_phase',\n message: `Board \"${target.boardKey}\" doesn't allow moving a card from its first phase \"${board.initialPhase}\" to \"${target.phaseKey}\".`,\n };\n }\n return undefined;\n}\n\n/**\n * On a board that reviews pull requests a pull request card works only in the pull request review\n * phase (it may also rest or finish), and nothing else lands in that review: a card arriving here\n * carries no attached pull request yet, and an existing issue card enters it only with one on it.\n * `FactoryTransitionService` refuses any move that breaks this, so a route can't either.\n */\nfunction placementTakesCard(\n board: InstalledBoard,\n phase: string,\n facts: RuleFacts,\n carriesPullRequest = false,\n): boolean {\n const flow = boardFlow(board);\n const review = flow.pullRequestReview;\n if (!review) return true;\n if (facts['source.kind'] !== 'pull_request') {\n // A board that reviews pull requests but builds nothing (the retired Review board) holds only them.\n if (flow.build === undefined) return false;\n return phase !== review || carriesPullRequest;\n }\n return phase === review || board.phaseKind(phase) !== 'working';\n}\n\n/**\n * What an intake route can test about the issue a pull request closes: whether there is one with\n * a card, that card's phase, and whether a pull request already sits on it. `closedIssue` is the\n * card the provider rules found, read fresh; undefined when the pull request closes none.\n */\nexport function closedIssueRuleFacts(closedIssue: Pick<Card, 'stages' | 'workItem'> | undefined): RuleFacts {\n if (!closedIssue) return { 'pullRequest.closesIssue': false };\n return {\n 'pullRequest.closesIssue': true,\n ...(closedIssue.stages.length === 1 ? { 'closedIssue.phase': closedIssue.stages[0] } : {}),\n 'closedIssue.hasPullRequest': hasPullRequest(closedIssue),\n };\n}\n\nexport type IntakeRouteResolution =\n | { type: 'place'; board: string; phase: string; routeId: string }\n | { type: 'join'; phase: string | null; routeId: string };\n\n/**\n * What happens to an arrival: the first enabled route that places new cards, whose condition matches it and whose\n * target can take it. A placing route lands a new card on an installed board; one without a\n * phase, or whose phase has since gone, lands it in the board's initial phase. A joining route\n * matches only a pull request whose closed issue's card (`closedIssue`) is on the route's board;\n * the pull request joins that card, which moves to the route's phase when set. Undefined leaves\n * today's placement alone.\n */\nexport function resolveIntakeRoute(\n routes: readonly IntakeRoute[],\n facts: RuleFacts,\n registry: BoardRegistry,\n closedIssue?: Pick<Card, 'board'>,\n): IntakeRouteResolution | undefined {\n for (const route of routes) {\n if (!route.enabled || !placesNewCards(route) || !evaluateRuleGroup(route.when, facts)) continue;\n const board = registry.get(route.target.boardKey);\n if (!board) continue;\n if (route.target.joinClosedIssue) {\n if (facts['source.kind'] !== 'pull_request' || !closedIssue || boardForWorkItem(closedIssue) !== board.id)\n continue;\n const phase = route.target.phaseKey;\n return {\n type: 'join',\n phase: phase && board.phaseKind(phase) && !board.isTerminal(phase) ? phase : null,\n routeId: route.id,\n };\n }\n const phase = landingPhase(board, route.target.phaseKey);\n if (!placementTakesCard(board, phase, facts)) continue;\n return { type: 'place', board: board.id, phase, routeId: route.id };\n }\n return undefined;\n}\n\n/** Where a new card lands, by {@link resolveIntakeRoute}, for an arrival no route can join to a card. */\nexport function resolveIntakePlacement(\n routes: readonly IntakeRoute[],\n facts: RuleFacts,\n registry: BoardRegistry,\n): { board: string; phase: string; routeId: string } | undefined {\n const resolution = resolveIntakeRoute(routes, facts, registry);\n return resolution?.type === 'place'\n ? { board: resolution.board, phase: resolution.phase, routeId: resolution.routeId }\n : undefined;\n}\n\n/** The phase a route's card lands in: its named phase when new cards can reach it, else the board's first. */\nexport function landingPhase(board: InstalledBoard, phase: string | null | undefined): string {\n const usable =\n phase &&\n board.phaseKind(phase) !== undefined &&\n !board.isTerminal(phase) &&\n board.allowsTransition(board.initialPhase, phase);\n return usable ? phase : board.initialPhase;\n}\n\n/** Whether any route on the board, enabled or not, handles the event: then the routes own it. */\nexport function routesHandleEvent(\n routes: readonly Pick<IntakeRoute, 'on' | 'target'>[],\n event: BoardEventFacts,\n board: Pick<InstalledBoard, 'id'>,\n): boolean {\n return routes.some(route => route.target.boardKey === board.id && route.on.includes(event.type));\n}\n\n/**\n * Where a status event moves an existing card: the first enabled route whose `on` names the\n * event, whose `when` matches the card and the event, and whose board is the card's own and can\n * hold it there. A route without a phase moves the card to its board's first phase. Undefined\n * leaves the card where it is.\n */\nexport function resolveEventRoute(\n routes: readonly IntakeRoute[],\n event: BoardEventFacts,\n cardFacts: RuleFacts,\n board: InstalledBoard,\n carriesPullRequest = false,\n): { phase: string; routeId: string } | undefined {\n const facts: RuleFacts = {\n ...cardFacts,\n 'event.type': event.type,\n ...(event.reason ? { 'event.reason': event.reason } : {}),\n };\n for (const route of routes) {\n if (!route.enabled || !route.on.includes(event.type) || route.target.boardKey !== board.id) continue;\n if (!evaluateRuleGroup(route.when, facts)) continue;\n const phase = route.target.phaseKey ?? board.initialPhase;\n if (board.phaseKind(phase) === undefined || !placementTakesCard(board, phase, facts, carriesPullRequest)) continue;\n return { phase, routeId: route.id };\n }\n return undefined;\n}\n"],"mappings":";;;;AAcA,SAAgB,eAAe,OAAqD;CAClF,OAAO,MAAM,GAAG,SAAS,mBAAmB;AAC9C;;;;;AAMA,MAAa,4BAA4B;;AAGzC,SAAgB,oBAAoB,MAAuC;CACzE,OAAO,OAAO,KAAK,WAAW,+BAA+B;AAC/D;;;;;;AAYA,SAAgB,oBACd,UACA,OACiC;CACjC,MAAM,EAAE,WAAW;CACnB,MAAM,QAAQ,SAAS,IAAI,OAAO,QAAQ;CAC1C,IAAI,CAAC,OACH,OAAO;EAAE,MAAM;EAAiB,SAAS,UAAU,OAAO,SAAS;CAAqC;CAE1G,IAAI,OAAO,mBAAmB,MAAM,GAAG,MAAK,UAAS,UAAU,mBAAmB,GAChF,OAAO;EACL,MAAM;EACN,SACE;CACJ;CAEF,IAAI,CAAC,OAAO,UAAU,OAAO,KAAA;CAC7B,IAAI,OAAO,mBAAmB,MAAM,UAAU,OAAO,QAAQ,MAAM,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,OACA,WACA,OACA,qBAAqB,OAC2B;CAChD,MAAM,QAAmB;EACvB,GAAG;EACH,cAAc,MAAM;EACpB,GAAI,MAAM,SAAS,EAAE,gBAAgB,MAAM,OAAO,IAAI,CAAC;CACzD;CACA,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,GAAG,SAAS,MAAM,IAAI,KAAK,MAAM,OAAO,aAAa,MAAM,IAAI;EAC5F,IAAI,CAAC,kBAAkB,MAAM,MAAM,KAAK,GAAG;EAC3C,MAAM,QAAQ,MAAM,OAAO,YAAY,MAAM;EAC7C,IAAI,MAAM,UAAU,KAAK,MAAM,KAAA,KAAa,CAAC,mBAAmB,OAAO,OAAO,OAAO,kBAAkB,GAAG;EAC1G,OAAO;GAAE;GAAO,SAAS,MAAM;EAAG;CACpC;AAEF"}
1
+ {"version":3,"file":"intake-routing.js","names":[],"sources":["../../src/boards/intake-routing.ts"],"sourcesContent":["import { evaluateRuleGroup, explainRuleGroup } from '../rules/rule-group.js';\nimport type { FailedRuleCondition, RuleFacts, RuleGroup } from '../rules/rule-group.js';\nimport { externalSourceForWorkItem } from '../rules/types.js';\nimport type { FactoryCommitDecision } from '../rules/types.js';\nimport type { IntakeEvaluator, StoredBoardsStorage, StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport type { BoardEventFacts, RouteArrivals } from './board-events.js';\nimport {\n arrivalKind,\n arrivalKinds,\n eventMovesCard,\n eventRuleFacts,\n isPullRequestEvent,\n LEGACY_ARRIVAL_EVENT,\n} from './board-events.js';\nimport { cardRuleFacts } from './card-facts.js';\nimport { deriveIntakeOrder, reconcileIntakeOrder } from './intake-order.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { boardFlow, boardForWorkItem, hasPullRequest, intakeTarget, isTerminalWorkItem } from './semantics.js';\n\n/** Reads a project's intake routes and intake order, and logs how intake decided each arrival. */\nexport type IntakeRoutesReader = Pick<\n StoredBoardsStorage,\n 'listIntakeRoutes' | 'readIntakeOrder' | 'recordIntakeDecision' | 'resolveNotRouted' | 'intakeEvaluator'\n>;\n\ntype IntakeRoute = Pick<StoredIntakeRouteRecord, 'id' | 'enabled' | 'when' | 'on' | 'pullRequestOpenedMovesOnly'> & {\n target: Pick<StoredIntakeRouteRecord['target'], 'boardKey' | 'phaseKey' | 'joinClosedIssue'> & {\n moveToBoardKey?: string | null;\n };\n} & Partial<Pick<StoredIntakeRouteRecord, 'name'>>;\n\n/** Whether the route places new cards, rather than only moving existing ones on later events. */\nexport function placesNewCards(route: RouteArrivals): boolean {\n return arrivalKinds(route).size > 0;\n}\n\n/**\n * Whether the route files this arrival: an issue by a `work_item.opened` route, a pull request with\n * no card by a `pull_request.opened` one, either by a legacy `work_item.created` one.\n */\nexport function placesArrival(route: RouteArrivals, facts: RuleFacts): boolean {\n return arrivalKinds(route).has(arrivalKind(facts));\n}\n\n/**\n * Why a route that files only issues, or only pull requests, passes over this arrival, put as the\n * `source.kind` condition it amounts to; undefined when the route files this kind.\n */\nfunction arrivalKindFailure(route: { on: readonly string[] }, facts: RuleFacts): FailedRuleCondition | undefined {\n if (placesArrival(route, facts)) return undefined;\n const actual = (facts['source.kind'] as FailedRuleCondition['actual'] | undefined) ?? null;\n return arrivalKind(facts) === 'pull_request'\n ? { field: 'source.kind', operator: 'not_equals', value: 'pull_request', actual }\n : { field: 'source.kind', operator: 'equals', value: 'pull_request', actual };\n}\n\n/**\n * Card metadata naming the intake route that placed the card. Label changes, rebinding its\n * source and replayed arrivals leave such a card where the route put it.\n */\nexport const INTAKE_ROUTE_METADATA_KEY = 'intakeRouteId';\n\n/** Whether an intake route chose this card's board when it arrived. */\nexport function placedByIntakeRoute(item: Pick<Card, 'metadata'>): boolean {\n return typeof item.metadata?.[INTAKE_ROUTE_METADATA_KEY] === 'string';\n}\n\nexport type IntakeTargetProblem = {\n code:\n | 'unknown_board'\n | 'unknown_phase'\n | 'terminal_phase'\n | 'unreachable_phase'\n | 'join_on_event'\n | 'move_on_arrival';\n message: string;\n};\n\n/**\n * Why a route's target can't take cards in this project, or undefined when it can. A route that\n * places new cards needs a phase they can reach; one that only moves existing cards on later\n * events, such as a close, may name any phase, terminal ones included.\n */\nexport function intakeTargetProblem(\n registry: BoardRegistry,\n route: RouteArrivals & {\n target: { boardKey: string; phaseKey?: string | null; joinClosedIssue?: boolean; moveToBoardKey?: string | null };\n },\n): IntakeTargetProblem | undefined {\n const { target } = route;\n const owner = registry.get(target.boardKey);\n if (!owner) {\n return { code: 'unknown_board', message: `Board \"${target.boardKey}\" is not installed in this project.` };\n }\n if (target.moveToBoardKey && (target.joinClosedIssue || placesNewCards(route))) {\n return {\n code: 'move_on_arrival',\n message:\n 'Only a route moving existing cards on later events can send them to another board: its `on` must not name an arrival event (`work_item.opened`, `pull_request.opened` or `work_item.created`).',\n };\n }\n const board = target.moveToBoardKey ? registry.get(target.moveToBoardKey) : owner;\n if (!board) {\n return { code: 'unknown_board', message: `Board \"${target.moveToBoardKey}\" is not installed in this project.` };\n }\n if (\n target.joinClosedIssue &&\n route.on.some(event => event !== 'pull_request.opened' && event !== LEGACY_ARRIVAL_EVENT)\n ) {\n return {\n code: 'join_on_event',\n message:\n 'A route that joins a pull request to the card of the issue it closes handles only pull requests arriving: its `on` must be `pull_request.opened` alone.',\n };\n }\n if (!target.phaseKey) return undefined;\n if (target.joinClosedIssue && board.phaseKind(target.phaseKey) === 'terminal') {\n return {\n code: 'terminal_phase',\n message: `Phase \"${target.phaseKey}\" on board \"${board.id}\" is terminal; a card a pull request joins can't move there.`,\n };\n }\n if (target.joinClosedIssue) {\n return board.phaseKind(target.phaseKey)\n ? undefined\n : { code: 'unknown_phase', message: `Board \"${board.id}\" has no phase \"${target.phaseKey}\".` };\n }\n const kind = board.phaseKind(target.phaseKey);\n if (!kind) {\n return { code: 'unknown_phase', message: `Board \"${board.id}\" has no phase \"${target.phaseKey}\".` };\n }\n if (!placesNewCards(route)) return undefined;\n if (kind === 'terminal') {\n return {\n code: 'terminal_phase',\n message: `Phase \"${target.phaseKey}\" on board \"${board.id}\" is terminal; new cards can't land there.`,\n };\n }\n if (!board.allowsTransition(board.initialPhase, target.phaseKey)) {\n return {\n code: 'unreachable_phase',\n message: `Board \"${board.id}\" doesn't allow moving a card from its first phase \"${board.initialPhase}\" to \"${target.phaseKey}\".`,\n };\n }\n return undefined;\n}\n\n/**\n * On a board that reviews pull requests a pull request card works only in the pull request review\n * phase (it may also rest or finish), and nothing else lands in that review: a card arriving here\n * carries no attached pull request yet, and an existing issue card enters it only with one on it.\n * `FactoryTransitionService` refuses any move that breaks this, so a route can't either.\n */\nfunction placementTakesCard(\n board: InstalledBoard,\n phase: string,\n facts: RuleFacts,\n carriesPullRequest = false,\n): boolean {\n const flow = boardFlow(board);\n const review = flow.pullRequestReview;\n if (!review) return true;\n if (facts['source.kind'] !== 'pull_request') {\n // A board that reviews pull requests but builds nothing (the retired Review board) holds only them.\n if (flow.build === undefined) return false;\n return phase !== review || carriesPullRequest;\n }\n return phase === review || board.phaseKind(phase) !== 'working';\n}\n\n/**\n * What an intake route can test about the issue a pull request closes: whether there is one with\n * a card, that card's phase, and whether a pull request already sits on it. `closedIssue` is the\n * card the provider rules found, read fresh; undefined when the pull request closes none.\n */\nexport function closedIssueRuleFacts(closedIssue: Pick<Card, 'stages' | 'workItem'> | undefined): RuleFacts {\n if (!closedIssue) return { 'pullRequest.closesIssue': false };\n return {\n 'pullRequest.closesIssue': true,\n 'item.hasIssue': true,\n ...(closedIssue.stages.length === 1 ? { 'closedIssue.phase': closedIssue.stages[0] } : {}),\n 'closedIssue.hasPullRequest': hasPullRequest(closedIssue),\n };\n}\n\n/**\n * Where a new card lands: the first enabled route that places new cards, whose condition matches\n * it and whose target can take it, on an installed board; a route without a phase, or whose phase\n * has since gone, lands it in the board's initial phase. Routes that once joined a pull request to\n * the card of the issue it closes place nothing: pull requests link to that card on their own.\n * Undefined leaves today's placement alone.\n */\nexport function resolveIntakePlacement(\n routes: readonly IntakeRoute[],\n facts: RuleFacts,\n registry: BoardRegistry,\n): { board: string; phase: string; routeId: string } | undefined {\n for (const route of routes) {\n if (!route.enabled || route.target.joinClosedIssue || !placesArrival(route, facts)) continue;\n if (!evaluateRuleGroup(route.when, facts)) continue;\n const board = registry.get(route.target.boardKey);\n if (!board) continue;\n const phase = landingPhase(board, route.target.phaseKey);\n if (!placementTakesCard(board, phase, facts)) continue;\n return { board: board.id, phase, routeId: route.id };\n }\n return undefined;\n}\n\n/** Where intake sends an arrival: placed on a board, or Not routed with the reason. */\nexport type IntakeResolution =\n | { outcome: 'placed'; board: string; phase: string; routeId: string | null }\n | { outcome: 'not_routed'; reason: string };\n\nexport interface IntakeQuery {\n evaluator: IntakeEvaluator;\n routes: readonly IntakeRoute[];\n /** Board keys in intake order; only the `intake-order` evaluator reads it. */\n order: readonly string[];\n facts: RuleFacts;\n registry: BoardRegistry;\n}\n\n/**\n * What intake rules test of an arrival: its own facts and, for a pull request closing an issue, that\n * issue's card as it is now (a finished card or one of another project counts as none). The\n * dispatcher and Route again both read an arrival through this, so they decide alike.\n */\nexport async function arrivalRuleFacts(\n decision: Extract<FactoryCommitDecision, { type: 'upsertLinkedWorkItem' }>,\n context: { factoryProjectId: string; registry: BoardRegistry; card(id: string): Promise<Card | null> },\n): Promise<RuleFacts> {\n const facts = cardRuleFacts({\n title: decision.title,\n metadata: decision.metadata ?? {},\n externalSource: externalSourceForWorkItem(decision.source, decision.sourceKey, decision.url ?? undefined),\n });\n if (!decision.closesIssue) return facts;\n const closed = await context.card(decision.closesIssue.workItemId);\n const open =\n closed && closed.factoryProjectId === context.factoryProjectId && !isTerminalWorkItem(context.registry, closed)\n ? closed\n : undefined;\n return { ...facts, ...closedIssueRuleFacts(open) };\n}\n\n/**\n * Prefixes the decision an admin's Route again commits. Such an arrival is resolved by intake order\n * whatever this replica's evaluator: only that evaluator leaves an item Not routed.\n */\nexport const ROUTE_AGAIN_KEY_PREFIX = 'intake-route-again:';\n\n/** The env var that forces an evaluator on every project when the Factory's `intake.evaluator` option doesn't. */\nexport const INTAKE_EVALUATOR_ENV = 'FACTORY_INTAKE_EVALUATOR';\n\n/** An evaluator this process forces on every project, and what forced it. */\nexport interface ForcedIntakeEvaluator {\n evaluator: IntakeEvaluator;\n source: 'option' | 'env';\n}\n\n/** Where a project's evaluator came from: forced, its own setting, or none (an older project). */\nexport type IntakeEvaluatorSource = ForcedIntakeEvaluator['source'] | 'project' | 'legacy';\n\n/**\n * The evaluator this process forces on every project: the configured one, else a valid\n * `FACTORY_INTAKE_EVALUATOR`. Undefined when neither is set: each project uses its own.\n */\nexport function intakeEvaluatorFrom(\n configured: IntakeEvaluator | undefined,\n env: Record<string, string | undefined> = process.env,\n): ForcedIntakeEvaluator | undefined {\n if (configured) return { evaluator: configured, source: 'option' };\n const value = env[INTAKE_EVALUATOR_ENV];\n return value === 'intake-order' || value === 'route-list' ? { evaluator: value, source: 'env' } : undefined;\n}\n\n/**\n * The evaluator that decides a project's arrivals: the forced one, else the project's setting\n * (`intake-order` for a project created since it shipped), else `route-list`.\n */\nexport async function projectIntakeEvaluator(\n forced: IntakeEvaluator | undefined,\n storage: Pick<StoredBoardsStorage, 'intakeEvaluator'>,\n scope: { orgId: string; factoryProjectId: string },\n): Promise<IntakeEvaluator> {\n return forced ?? (await storage.intakeEvaluator(scope)) ?? 'route-list';\n}\n\n/** Where intake sends an arrival, by the evaluator `query` names. Join routes never place here. */\nexport function resolveIntake(query: IntakeQuery): IntakeResolution {\n return query.evaluator === 'intake-order' ? resolveByIntakeOrder(query) : resolveByRouteList(query);\n}\n\n/** How many of a project's newest cards {@link compareIntakeOrder} reads. */\nexport const INTAKE_ORDER_SAMPLE = 200;\n\nexport interface IntakeOrderComparison {\n /** Cards compared: the project's newest, at most {@link INTAKE_ORDER_SAMPLE}. */\n compared: number;\n /** Of those, how many the intake order would place on another board than the route list does. */\n differing: number;\n /** Of those, how many no board's rules take under the intake order. */\n notRouted: number;\n}\n\n/**\n * Runs both evaluators over `cards` (newest first) as if each arrived now, so an admin sees what\n * switching to `order` changes before switching.\n */\nexport function compareIntakeOrder(\n query: Pick<IntakeQuery, 'routes' | 'order' | 'registry'> & { cards: readonly Card[] },\n): IntakeOrderComparison {\n const sample = query.cards.slice(0, INTAKE_ORDER_SAMPLE);\n let differing = 0;\n let notRouted = 0;\n for (const card of sample) {\n const base = { routes: query.routes, order: query.order, registry: query.registry, facts: cardRuleFacts(card) };\n const old = resolveIntake({ ...base, evaluator: 'route-list' });\n const next = resolveIntake({ ...base, evaluator: 'intake-order' });\n if (next.outcome === 'not_routed') notRouted += 1;\n if (placedOn(old) !== placedOn(next)) differing += 1;\n }\n return { compared: sample.length, differing, notRouted };\n}\n\nfunction placedOn(resolution: IntakeResolution): string | null {\n return resolution.outcome === 'placed' ? resolution.board : null;\n}\n\n/** How one intake rule answered an item, in the order intake asked it. */\nexport type IntakeRuleVerdict =\n /** It took the item: the first enabled rule, in intake order, that matched and whose phase takes it. */\n | { outcome: 'took' }\n /** It matched and its phase takes the item, but a rule asked earlier took it first. */\n | { outcome: 'lost'; to: { boardKey: string; routeId: string } }\n /** Its condition failed; `failed` names the conditions it failed on. */\n | { outcome: 'no_match'; failed: FailedRuleCondition[] }\n /** It matched, but its phase can't hold this kind of item (such as an issue in a pull request review phase). */\n | { outcome: 'phase_refuses' }\n /** It is switched off. */\n | { outcome: 'disabled' };\n\nexport type IntakeRuleTrace = IntakeRuleVerdict & {\n routeId: string;\n name: string | null;\n /** The phase the item would land in from this rule. */\n phase: string;\n};\n\nexport interface IntakeBoardTrace {\n boardKey: string;\n name: string;\n /** The board's rules that place new items, top to bottom. */\n rules: IntakeRuleTrace[];\n}\n\nexport interface IntakeTrace {\n resolution: IntakeResolution;\n /** Boards in the order intake asked them; with `full`, every board, even after one took the item. */\n boards: IntakeBoardTrace[];\n}\n\n/**\n * Asks boards in intake order, and inside each board its own rules top to bottom: the first\n * enabled placing rule that matches and whose phase can take the card decides. Nothing names a\n * board to fall back to; an arrival no board takes is Not routed. Filing stops at the winner;\n * `full` keeps asking every rule after it, so the dry run and tester can show which rules\n * matched but lost. Both read the same verdicts, so what they show is what filing does.\n */\nexport function traceIntakeOrder(\n { routes, order, facts, registry }: Omit<IntakeQuery, 'evaluator'>,\n options: { full?: boolean } = {},\n): IntakeTrace {\n const boards: IntakeBoardTrace[] = [];\n let resolution: Extract<IntakeResolution, { outcome: 'placed' }> | undefined;\n let winner: { boardKey: string; routeId: string } | undefined;\n // A code board isn't stored, so the stored order can lack it; it slots in as a new board does.\n const boardKeys = [...registry.keys()];\n const stored = order.length > 0 ? order : deriveIntakeOrder(routes, boardKeys);\n for (const boardKey of reconcileIntakeOrder(stored, boardKeys, routes)) {\n const board = registry.get(boardKey);\n if (!board) continue;\n const trace: IntakeBoardTrace = { boardKey: board.id, name: board.name, rules: [] };\n boards.push(trace);\n for (const route of routes) {\n if (route.target.boardKey !== boardKey || route.target.joinClosedIssue || !placesNewCards(route)) continue;\n const phase = landingPhase(board, route.target.phaseKey);\n const rule = { routeId: route.id, name: route.name ?? null, phase };\n if (!route.enabled) {\n trace.rules.push({ ...rule, outcome: 'disabled' });\n continue;\n }\n const kindFailed = arrivalKindFailure(route, facts);\n if (kindFailed) {\n trace.rules.push({ ...rule, outcome: 'no_match', failed: [kindFailed] });\n continue;\n }\n const explained = explainRuleGroup(route.when, facts);\n if (!explained.matched) {\n trace.rules.push({ ...rule, outcome: 'no_match', failed: explained.failed });\n continue;\n }\n if (!placementTakesCard(board, phase, facts)) {\n trace.rules.push({ ...rule, outcome: 'phase_refuses' });\n continue;\n }\n if (winner) {\n trace.rules.push({ ...rule, outcome: 'lost', to: winner });\n continue;\n }\n trace.rules.push({ ...rule, outcome: 'took' });\n winner = { boardKey: board.id, routeId: route.id };\n resolution = { outcome: 'placed', board: board.id, phase, routeId: route.id };\n if (!options.full) return { resolution, boards };\n }\n }\n if (resolution) return { resolution, boards };\n const checked = boards.map(board => board.name);\n return {\n resolution: {\n outcome: 'not_routed',\n reason:\n checked.length > 0\n ? `No board's intake rules match it (checked ${checked.join(', ')}).`\n : 'The project has no board to take it.',\n },\n boards,\n };\n}\n\nfunction resolveByIntakeOrder(query: IntakeQuery): IntakeResolution {\n return traceIntakeOrder(query).resolution;\n}\n\n/**\n * The old evaluator, kept behind the flag until every replica runs the new one: the first\n * matching route of the whole list, else the default board's first phase, else the first board.\n * The only place intake still names a default board; delete it with the flag.\n */\nfunction resolveByRouteList({ routes, facts, registry }: IntakeQuery): IntakeResolution {\n const placement = resolveIntakePlacement(routes, facts, registry);\n if (placement) return { outcome: 'placed', ...placement };\n const fallback = intakeTarget(registry);\n return fallback\n ? { outcome: 'placed', board: fallback.board, phase: fallback.initialPhase, routeId: null }\n : { outcome: 'not_routed', reason: 'The project has no board to take it.' };\n}\n\n/** The phase a route's card lands in: its named phase when new cards can reach it, else the board's first. */\nexport function landingPhase(board: InstalledBoard, phase: string | null | undefined): string {\n const usable =\n phase &&\n board.phaseKind(phase) !== undefined &&\n !board.isTerminal(phase) &&\n board.allowsTransition(board.initialPhase, phase);\n return usable ? phase : board.initialPhase;\n}\n\n/** Whether any route on the board, enabled or not, handles the event: then the routes own it. */\nexport function routesHandleEvent(\n routes: readonly Pick<IntakeRoute, 'on' | 'target'>[],\n event: BoardEventFacts,\n board: Pick<InstalledBoard, 'id'>,\n): boolean {\n return routes.some(route => route.target.boardKey === board.id && route.on.includes(event.type));\n}\n\nconst SETTLING_PULL_REQUEST_EVENTS = new Set<string>(['pull_request.merged', 'pull_request.closed']);\n\nfunction testsField(group: RuleGroup | null, field: string): boolean {\n return (\n group?.conditions.some(member => ('field' in member ? member.field === field : testsField(member, field))) ?? false\n );\n}\n\n/** A card-move route that matched but can't take the card where it points, and why. */\nexport interface SkippedEventRoute {\n routeId: string;\n /** The board the rule points the card to. */\n boardKey: string;\n reason: string;\n}\n\n/** A card move: the board, phase and rule an event sends the card to. */\nexport interface EventMove {\n board: string;\n phase: string;\n routeId: string;\n}\n\n/** What one card-move rule answered for an event. */\nexport type EventRuleVerdict =\n | { outcome: 'took' }\n | { outcome: 'lost'; to: { boardKey: string; routeId: string } }\n | { outcome: 'no_match'; failed: FailedRuleCondition[] }\n | { outcome: 'skipped'; reason: string }\n | { outcome: 'disabled' };\n\nexport type EventRuleTrace = { routeId: string; name: string | null } & EventRuleVerdict;\n\n/**\n * Every rule on the card's board whose `on` names the event, top to bottom, and what each\n * answered: the first enabled one whose `when` matches the card and the event, and whose target\n * can hold the card, moves it. The target is the route's own board unless it names another\n * (`moveToBoardKey`); a route without a phase moves the card to the target board's first phase.\n * A matching route whose target is gone or can't take the card is skipped and reported through\n * `onSkip`. Filing stops at the winner; `full` keeps asking, so the tester shows what it beat.\n */\nexport function traceEventRoute(\n routes: readonly IntakeRoute[],\n event: BoardEventFacts,\n cardFacts: RuleFacts,\n board: InstalledBoard,\n options: { registry: BoardRegistry; carriesPullRequest?: boolean; onSkip?: (skipped: SkippedEventRoute) => void },\n { full = false }: { full?: boolean } = {},\n): { move: EventMove | undefined; rules: EventRuleTrace[] } {\n const { 'pullRequest.trusted': workingPullRequestTrusted, ...rest } = cardFacts;\n // On a pull request event, `pullRequest.trusted` is that pull request's author, not the card's\n // working pull request's; an event that doesn't say is untrusted.\n const pullRequestTrusted = isPullRequestEvent(event.type) ? event.pullRequestTrusted : workingPullRequestTrusted;\n const facts: RuleFacts = {\n ...rest,\n ...(pullRequestTrusted !== undefined ? { 'pullRequest.trusted': pullRequestTrusted } : {}),\n ...eventRuleFacts(event),\n ...(event.closedIssue\n ? {\n 'pullRequest.closesIssue': true,\n ...(event.closedIssue.phase !== null ? { 'closedIssue.phase': event.closedIssue.phase } : {}),\n 'closedIssue.hasPullRequest': event.closedIssue.hasPullRequest,\n }\n : {}),\n };\n // An outsider's pull request linked to an issue's card moves the card only by a rule that asks\n // about the pull request's trust; one that doesn't was never written with outsiders in mind.\n // Merging and closing settle the pull request either way, so those still move the card.\n const untrustedLinkedPullRequest =\n isPullRequestEvent(event.type) &&\n !SETTLING_PULL_REQUEST_EVENTS.has(event.type) &&\n cardFacts['source.kind'] !== 'pull_request' &&\n pullRequestTrusted !== true;\n const rules: EventRuleTrace[] = [];\n let move: EventMove | undefined;\n for (const route of routes) {\n if (!route.on.includes(event.type) || route.target.boardKey !== board.id) continue;\n const named = { routeId: route.id, name: route.name ?? null };\n if (!route.enabled) {\n rules.push({ ...named, outcome: 'disabled' });\n continue;\n }\n // Not a skip the dispatcher logs: the rule was never meant for this pull request.\n if (untrustedLinkedPullRequest && !testsField(route.when, 'pullRequest.trusted')) {\n rules.push({\n ...named,\n outcome: 'skipped',\n reason: \"the pull request's author is an outsider, and this rule doesn't test pullRequest.trusted\",\n });\n continue;\n }\n const { matched, failed } = explainRuleGroup(route.when, facts);\n if (!matched) {\n rules.push({ ...named, outcome: 'no_match', failed });\n continue;\n }\n const targetKey = route.target.moveToBoardKey ?? board.id;\n const skip = (reason: string) => {\n // Filing never reaches a rule past the winner, so only those before it are logged.\n if (!move) options.onSkip?.({ routeId: route.id, boardKey: targetKey, reason });\n rules.push({ ...named, outcome: 'skipped', reason });\n };\n const target = targetKey === board.id ? board : options.registry.get(targetKey);\n if (!target) {\n skip(`board \"${targetKey}\" is not installed`);\n continue;\n }\n const phase = route.target.phaseKey ?? target.initialPhase;\n if (target.phaseKind(phase) === undefined) {\n skip(`board \"${target.id}\" has no phase \"${phase}\"`);\n continue;\n }\n if (!placementTakesCard(target, phase, facts, options.carriesPullRequest ?? false)) {\n skip(`phase \"${phase}\" on board \"${target.id}\" can't hold this card`);\n continue;\n }\n // A rule that could have taken the card, had an earlier one not.\n if (move) {\n rules.push({ ...named, outcome: 'lost', to: { boardKey: move.board, routeId: move.routeId } });\n continue;\n }\n move = { board: target.id, phase, routeId: route.id };\n rules.push({ ...named, outcome: 'took' });\n if (!full) break;\n }\n return { move, rules };\n}\n\n/** Where a status event moves an existing card, by {@link traceEventRoute}; undefined leaves it where it is. */\nexport function resolveEventRoute(\n routes: readonly IntakeRoute[],\n event: BoardEventFacts,\n cardFacts: RuleFacts,\n board: InstalledBoard,\n options: { registry: BoardRegistry; carriesPullRequest?: boolean; onSkip?: (skipped: SkippedEventRoute) => void },\n): EventMove | undefined {\n return traceEventRoute(routes, event, cardFacts, board, options).move;\n}\n\n/**\n * What a status event does to a card: `moves` it where a route sends it; `stays` when a route on\n * its board handles the event but none moves it anywhere new; `rule_default` when the\n * integration's own move (`fallback`, if any) applies because no route handles the event, or a\n * pull request event's route didn't take the card; `ignored` when the event can't move a card in\n * its state (a reopen of an unfinished card, a close of a finished one) or its board is gone.\n */\nexport type EventMovePlan = { rules: EventRuleTrace[] } & (\n | { outcome: 'moves'; move: EventMove }\n | { outcome: 'stays' }\n | { outcome: 'rule_default'; phase: string | null }\n | { outcome: 'ignored'; reason: string }\n);\n\n/** Decides a status event on a card the way the dispatcher files it; the tester replays events through it. */\nexport function planEventMove(\n input: {\n routes: readonly IntakeRoute[];\n event: BoardEventFacts;\n item: Card;\n registry: BoardRegistry;\n /** The integration's own move for this event, when it proposed one. */\n fallback?: { stage: string };\n onSkip?: (skipped: SkippedEventRoute) => void;\n },\n options: { full?: boolean } = {},\n): EventMovePlan {\n const { routes, event, item, registry, fallback } = input;\n const board = registry.get(boardForWorkItem(item));\n if (!board) return { outcome: 'ignored', reason: \"The card's board isn't installed.\", rules: [] };\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n const finished = stage !== undefined && board.isTerminal(stage);\n if (!eventMovesCard(event.type, finished)) {\n return {\n outcome: 'ignored',\n reason: finished ? \"A finished card doesn't move on this event.\" : 'Only a finished card moves on this event.',\n rules: [],\n };\n }\n const defaulted = { outcome: 'rule_default' as const, phase: fallback?.stage ?? null };\n if (!routesHandleEvent(routes, event, board)) return { ...defaulted, rules: [] };\n const facts = { ...cardRuleFacts(item), ...(stage !== undefined ? { 'card.phase': stage } : {}) };\n const { move, rules } = traceEventRoute(\n routes,\n event,\n facts,\n board,\n { registry, carriesPullRequest: hasPullRequest(item), ...(input.onSkip && { onSkip: input.onSkip }) },\n options,\n );\n // A pull request event the rules already decided keeps that decision when no enabled route\n // takes the card: disabling or narrowing a route must not strand a merged card in review.\n if (!move) return fallback && isPullRequestEvent(event.type) ? { ...defaulted, rules } : { outcome: 'stays', rules };\n const crossesBoards = move.board !== board.id;\n // A route that agrees with the rule's own pull request move keeps it whole: its message, and\n // the re-entry that restarts a review in the phase the card already sits in.\n if (!crossesBoards && fallback && isPullRequestEvent(event.type) && move.phase === fallback.stage) {\n return { ...defaulted, rules };\n }\n if (!crossesBoards && stage === move.phase) return { outcome: 'stays', rules };\n return { outcome: 'moves', move, rules };\n}\n"],"mappings":";;;;;;;;AAiCA,SAAgB,eAAe,OAA+B;CAC5D,OAAO,aAAa,KAAK,CAAC,CAAC,OAAO;AACpC;;;;;AAMA,SAAgB,cAAc,OAAsB,OAA2B;CAC7E,OAAO,aAAa,KAAK,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC;AACnD;;;;;AAMA,SAAS,mBAAmB,OAAkC,OAAmD;CAC/G,IAAI,cAAc,OAAO,KAAK,GAAG,OAAO,KAAA;CACxC,MAAM,SAAU,MAAM,kBAAgE;CACtF,OAAO,YAAY,KAAK,MAAM,iBAC1B;EAAE,OAAO;EAAe,UAAU;EAAc,OAAO;EAAgB;CAAO,IAC9E;EAAE,OAAO;EAAe,UAAU;EAAU,OAAO;EAAgB;CAAO;AAChF;;;;;AAMA,MAAa,4BAA4B;;AAGzC,SAAgB,oBAAoB,MAAuC;CACzE,OAAO,OAAO,KAAK,WAAW,+BAA+B;AAC/D;;;;;;AAkBA,SAAgB,oBACd,UACA,OAGiC;CACjC,MAAM,EAAE,WAAW;CACnB,MAAM,QAAQ,SAAS,IAAI,OAAO,QAAQ;CAC1C,IAAI,CAAC,OACH,OAAO;EAAE,MAAM;EAAiB,SAAS,UAAU,OAAO,SAAS;CAAqC;CAE1G,IAAI,OAAO,mBAAmB,OAAO,mBAAmB,eAAe,KAAK,IAC1E,OA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AS;EAAM;CAAM;AACzC"}
@@ -1,4 +1,4 @@
1
- import type { StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';
1
+ import type { IntakeEvaluator, StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';
2
2
  import type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';
3
3
  import type { BoardRegistry } from './registry.js';
4
4
  export type RerouteMove = {
@@ -10,9 +10,13 @@ export type RerouteMove = {
10
10
  };
11
11
  /**
12
12
  * Which untouched cards the routes, as they stand, would file on a different board. Each lands at
13
- * the start of its new board. A card no route places stays where it is.
13
+ * the start of its new board. A card no route places stays where it is. Under `intake-order` the
14
+ * boards are asked in `order`, as a new arrival would be.
14
15
  */
15
- export declare function planReroute(routes: readonly StoredIntakeRouteRecord[], items: readonly Card[], registry: BoardRegistry): RerouteMove[];
16
+ export declare function planReroute(routes: readonly StoredIntakeRouteRecord[], items: readonly Card[], registry: BoardRegistry, intake?: {
17
+ evaluator: IntakeEvaluator;
18
+ order: readonly string[];
19
+ }): RerouteMove[];
16
20
  /** How many cards a plan moves from each board to each other board. */
17
21
  export declare function summarizeReroute(moves: readonly RerouteMove[]): {
18
22
  fromBoard: string;
@@ -1 +1 @@
1
- {"version":3,"file":"reroute.d.ts","sourceRoot":"","sources":["../../src/boards/reroute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAY/G;;;GAGG;AACH,wBAAgB,WAA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1C,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,aAAa,EACvB,MAAM,GAAE;IAAE,SAAS,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAA2C,GACxG,WAAW,EAAE,CAYf;AAeD,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,WAAW,EAAE,GAC5B;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CASzD;AAED,wBAAsB,YAAY,CAAC,EACjC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,+BAA+B,CAAC,CAAC;IAC9E,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB9C"}
@@ -1,5 +1,5 @@
1
1
  import { cardRuleFacts } from "./card-facts.js";
2
- import { resolveIntakePlacement } from "./intake-routing.js";
2
+ import { resolveIntake, resolveIntakePlacement } from "./intake-routing.js";
3
3
  import { effectiveBoard, moveCardToBoard } from "./relocate.js";
4
4
  // src/boards/reroute.ts
5
5
  /**
@@ -13,13 +13,17 @@ function untouched(item, registry) {
13
13
  }
14
14
  /**
15
15
  * Which untouched cards the routes, as they stand, would file on a different board. Each lands at
16
- * the start of its new board. A card no route places stays where it is.
16
+ * the start of its new board. A card no route places stays where it is. Under `intake-order` the
17
+ * boards are asked in `order`, as a new arrival would be.
17
18
  */
18
- function planReroute(routes, items, registry) {
19
+ function planReroute(routes, items, registry, intake = {
20
+ evaluator: "route-list",
21
+ order: []
22
+ }) {
19
23
  const moves = [];
20
24
  for (const item of items) {
21
25
  if (!untouched(item, registry)) continue;
22
- const placement = resolveIntakePlacement(routes, cardRuleFacts(item), registry);
26
+ const placement = placementOf(routes, item, registry, intake);
23
27
  if (!placement) continue;
24
28
  const fromBoard = effectiveBoard(item);
25
29
  if (placement.board === fromBoard) continue;
@@ -34,6 +38,19 @@ function planReroute(routes, items, registry) {
34
38
  }
35
39
  return moves;
36
40
  }
41
+ function placementOf(routes, item, registry, intake) {
42
+ if (intake.evaluator === "route-list") return resolveIntakePlacement(routes, cardRuleFacts(item), registry);
43
+ const resolution = resolveIntake({
44
+ ...intake,
45
+ routes,
46
+ facts: cardRuleFacts(item),
47
+ registry
48
+ });
49
+ return resolution.outcome === "placed" && resolution.routeId !== null ? {
50
+ board: resolution.board,
51
+ routeId: resolution.routeId
52
+ } : void 0;
53
+ }
37
54
  /** How many cards a plan moves from each board to each other board. */
38
55
  function summarizeReroute(moves) {
39
56
  const counts = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"reroute.js","names":[],"sources":["../../src/boards/reroute.ts"],"sourcesContent":["import type { StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { cardRuleFacts } from './card-facts.js';\nimport { resolveIntakePlacement } from './intake-routing.js';\nimport type { BoardRegistry } from './registry.js';\nimport { effectiveBoard, moveCardToBoard } from './relocate.js';\n\nexport type RerouteMove = { item: Card; fromBoard: string; toBoard: string; toPhase: string; routeId: string };\n\n/**\n * A card nobody has worked yet: it sits alone in its board's first phase with no session on it.\n * Only such cards follow a change to the intake routes; anything further along stays put.\n */\nfunction untouched(item: Card, registry: BoardRegistry): boolean {\n const board = registry.get(effectiveBoard(item));\n if (!board) return false;\n return item.stages.length === 1 && item.stages[0] === board.initialPhase && Object.keys(item.sessions).length === 0;\n}\n\n/**\n * Which untouched cards the routes, as they stand, would file on a different board. Each lands at\n * the start of its new board. A card no route places stays where it is.\n */\nexport function planReroute(\n routes: readonly StoredIntakeRouteRecord[],\n items: readonly Card[],\n registry: BoardRegistry,\n): RerouteMove[] {\n const moves: RerouteMove[] = [];\n for (const item of items) {\n if (!untouched(item, registry)) continue;\n const placement = resolveIntakePlacement(routes, cardRuleFacts(item), registry);\n if (!placement) continue;\n const fromBoard = effectiveBoard(item);\n if (placement.board === fromBoard) continue;\n const target = registry.get(placement.board)!;\n moves.push({ item, fromBoard, toBoard: placement.board, toPhase: target.initialPhase, routeId: placement.routeId });\n }\n return moves;\n}\n\n/** How many cards a plan moves from each board to each other board. */\nexport function summarizeReroute(\n moves: readonly RerouteMove[],\n): { fromBoard: string; toBoard: string; count: number }[] {\n const counts = new Map<string, { fromBoard: string; toBoard: string; count: number }>();\n for (const { fromBoard, toBoard } of moves) {\n const key = `${fromBoard}\\u0000${toBoard}`;\n const entry = counts.get(key) ?? { fromBoard, toBoard, count: 0 };\n entry.count += 1;\n counts.set(key, entry);\n }\n return [...counts.values()];\n}\n\nexport async function applyReroute({\n moves,\n workItems,\n registry,\n userId,\n}: {\n moves: readonly RerouteMove[];\n workItems: Pick<WorkItemsStorage, 'update' | 'supersedeDecisionsForWorkItem'>;\n registry: BoardRegistry;\n userId: string;\n}): Promise<{ moved: number; skipped: number }> {\n let moved = 0;\n let skipped = 0;\n for (const move of moves) {\n const result = await moveCardToBoard({\n workItems,\n boardRegistry: registry,\n userId,\n item: move.item,\n targetBoard: move.toBoard,\n targetStage: move.toPhase,\n });\n if (result === 'moved') moved += 1;\n else skipped += 1;\n }\n return { moved, skipped };\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAAY,UAAkC;CAC/D,MAAM,QAAQ,SAAS,IAAI,eAAe,IAAI,CAAC;CAC/C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK,OAAO,OAAO,MAAM,gBAAgB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,WAAW;AACpH;;;;;AAMA,SAAgB,YACd,QACA,OACA,UACe;CACf,MAAM,QAAuB,CAAC;CAC9B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,UAAU,MAAM,QAAQ,GAAG;EAChC,MAAM,YAAY,uBAAuB,QAAQ,cAAc,IAAI,GAAG,QAAQ;EAC9E,IAAI,CAAC,WAAW;EAChB,MAAM,YAAY,eAAe,IAAI;EACrC,IAAI,UAAU,UAAU,WAAW;EACnC,MAAM,SAAS,SAAS,IAAI,UAAU,KAAK;EAC3C,MAAM,KAAK;GAAE;GAAM;GAAW,SAAS,UAAU;GAAO,SAAS,OAAO;GAAc,SAAS,UAAU;EAAQ,CAAC;CACpH;CACA,OAAO;AACT;;AAGA,SAAgB,iBACd,OACyD;CACzD,MAAM,yBAAS,IAAI,IAAmE;CACtF,KAAK,MAAM,EAAE,WAAW,aAAa,OAAO;EAC1C,MAAM,MAAM,GAAG,UAAU,QAAQ;EACjC,MAAM,QAAQ,OAAO,IAAI,GAAG,KAAK;GAAE;GAAW;GAAS,OAAO;EAAE;EAChE,MAAM,SAAS;EACf,OAAO,IAAI,KAAK,KAAK;CACvB;CACA,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;AAC5B;AAEA,eAAsB,aAAa,EACjC,OACA,WACA,UACA,UAM8C;CAC9C,IAAI,QAAQ;CACZ,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OASjB,IAAI,MARiB,gBAAgB;EACnC;EACA,eAAe;EACf;EACA,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,aAAa,KAAK;CACpB,CAAC,MACc,SAAS,SAAS;MAC5B,WAAW;CAElB,OAAO;EAAE;EAAO;CAAQ;AAC1B"}
1
+ {"version":3,"file":"reroute.js","names":[],"sources":["../../src/boards/reroute.ts"],"sourcesContent":["import type { IntakeEvaluator, StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { cardRuleFacts } from './card-facts.js';\nimport { resolveIntake, resolveIntakePlacement } from './intake-routing.js';\nimport type { BoardRegistry } from './registry.js';\nimport { effectiveBoard, moveCardToBoard } from './relocate.js';\n\nexport type RerouteMove = { item: Card; fromBoard: string; toBoard: string; toPhase: string; routeId: string };\n\n/**\n * A card nobody has worked yet: it sits alone in its board's first phase with no session on it.\n * Only such cards follow a change to the intake routes; anything further along stays put.\n */\nfunction untouched(item: Card, registry: BoardRegistry): boolean {\n const board = registry.get(effectiveBoard(item));\n if (!board) return false;\n return item.stages.length === 1 && item.stages[0] === board.initialPhase && Object.keys(item.sessions).length === 0;\n}\n\n/**\n * Which untouched cards the routes, as they stand, would file on a different board. Each lands at\n * the start of its new board. A card no route places stays where it is. Under `intake-order` the\n * boards are asked in `order`, as a new arrival would be.\n */\nexport function planReroute(\n routes: readonly StoredIntakeRouteRecord[],\n items: readonly Card[],\n registry: BoardRegistry,\n intake: { evaluator: IntakeEvaluator; order: readonly string[] } = { evaluator: 'route-list', order: [] },\n): RerouteMove[] {\n const moves: RerouteMove[] = [];\n for (const item of items) {\n if (!untouched(item, registry)) continue;\n const placement = placementOf(routes, item, registry, intake);\n if (!placement) continue;\n const fromBoard = effectiveBoard(item);\n if (placement.board === fromBoard) continue;\n const target = registry.get(placement.board)!;\n moves.push({ item, fromBoard, toBoard: placement.board, toPhase: target.initialPhase, routeId: placement.routeId });\n }\n return moves;\n}\n\nfunction placementOf(\n routes: readonly StoredIntakeRouteRecord[],\n item: Card,\n registry: BoardRegistry,\n intake: { evaluator: IntakeEvaluator; order: readonly string[] },\n): { board: string; routeId: string } | undefined {\n if (intake.evaluator === 'route-list') return resolveIntakePlacement(routes, cardRuleFacts(item), registry);\n const resolution = resolveIntake({ ...intake, routes, facts: cardRuleFacts(item), registry });\n return resolution.outcome === 'placed' && resolution.routeId !== null\n ? { board: resolution.board, routeId: resolution.routeId }\n : undefined;\n}\n\n/** How many cards a plan moves from each board to each other board. */\nexport function summarizeReroute(\n moves: readonly RerouteMove[],\n): { fromBoard: string; toBoard: string; count: number }[] {\n const counts = new Map<string, { fromBoard: string; toBoard: string; count: number }>();\n for (const { fromBoard, toBoard } of moves) {\n const key = `${fromBoard}\\u0000${toBoard}`;\n const entry = counts.get(key) ?? { fromBoard, toBoard, count: 0 };\n entry.count += 1;\n counts.set(key, entry);\n }\n return [...counts.values()];\n}\n\nexport async function applyReroute({\n moves,\n workItems,\n registry,\n userId,\n}: {\n moves: readonly RerouteMove[];\n workItems: Pick<WorkItemsStorage, 'update' | 'supersedeDecisionsForWorkItem'>;\n registry: BoardRegistry;\n userId: string;\n}): Promise<{ moved: number; skipped: number }> {\n let moved = 0;\n let skipped = 0;\n for (const move of moves) {\n const result = await moveCardToBoard({\n workItems,\n boardRegistry: registry,\n userId,\n item: move.item,\n targetBoard: move.toBoard,\n targetStage: move.toPhase,\n });\n if (result === 'moved') moved += 1;\n else skipped += 1;\n }\n return { moved, skipped };\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAAY,UAAkC;CAC/D,MAAM,QAAQ,SAAS,IAAI,eAAe,IAAI,CAAC;CAC/C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK,OAAO,OAAO,MAAM,gBAAgB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,WAAW;AACpH;;;;;;AAOA,SAAgB,YACd,QACA,OACA,UACA,SAAmE;CAAE,WAAW;CAAc,OAAO,CAAC;AAAE,GACzF;CACf,MAAM,QAAuB,CAAC;CAC9B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,UAAU,MAAM,QAAQ,GAAG;EAChC,MAAM,YAAY,YAAY,QAAQ,MAAM,UAAU,MAAM;EAC5D,IAAI,CAAC,WAAW;EAChB,MAAM,YAAY,eAAe,IAAI;EACrC,IAAI,UAAU,UAAU,WAAW;EACnC,MAAM,SAAS,SAAS,IAAI,UAAU,KAAK;EAC3C,MAAM,KAAK;GAAE;GAAM;GAAW,SAAS,UAAU;GAAO,SAAS,OAAO;GAAc,SAAS,UAAU;EAAQ,CAAC;CACpH;CACA,OAAO;AACT;AAEA,SAAS,YACP,QACA,MACA,UACA,QACgD;CAChD,IAAI,OAAO,cAAc,cAAc,OAAO,uBAAuB,QAAQ,cAAc,IAAI,GAAG,QAAQ;CAC1G,MAAM,aAAa,cAAc;EAAE,GAAG;EAAQ;EAAQ,OAAO,cAAc,IAAI;EAAG;CAAS,CAAC;CAC5F,OAAO,WAAW,YAAY,YAAY,WAAW,YAAY,OAC7D;EAAE,OAAO,WAAW;EAAO,SAAS,WAAW;CAAQ,IACvD,KAAA;AACN;;AAGA,SAAgB,iBACd,OACyD;CACzD,MAAM,yBAAS,IAAI,IAAmE;CACtF,KAAK,MAAM,EAAE,WAAW,aAAa,OAAO;EAC1C,MAAM,MAAM,GAAG,UAAU,QAAQ;EACjC,MAAM,QAAQ,OAAO,IAAI,GAAG,KAAK;GAAE;GAAW;GAAS,OAAO;EAAE;EAChE,MAAM,SAAS;EACf,OAAO,IAAI,KAAK,KAAK;CACvB;CACA,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;AAC5B;AAEA,eAAsB,aAAa,EACjC,OACA,WACA,UACA,UAM8C;CAC9C,IAAI,QAAQ;CACZ,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OASjB,IAAI,MARiB,gBAAgB;EACnC;EACA,eAAe;EACf;EACA,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,aAAa,KAAK;CACpB,CAAC,MACc,SAAS,SAAS;MAC5B,WAAW;CAElB,OAAO;EAAE;EAAO;CAAQ;AAC1B"}
@@ -2,6 +2,7 @@ import type { FactoryRuleBoardClosure, FactoryRuleBoardFlow, FactoryRuleIntakeTa
2
2
  import type { Card } from '../storage/domains/work-items/base.js';
3
3
  import type { MetricsPhaseOutcomes } from '../storage/domains/work-items/metrics.js';
4
4
  import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';
5
+ import type { SourcedItem } from '../work-items/change-requests.js';
5
6
  import type { BoardEventIntegration, BoardEventRules, BoardPhaseKind, BoardToolResultRuleHandler } from './define-board.js';
6
7
  import type { BoardRegistry, InstalledBoard } from './registry.js';
7
8
  export interface PhaseSemantics {
@@ -72,36 +73,10 @@ export declare function pullRequestCardRejection(board: InstalledBoard, card: {
72
73
  export declare function withBoardFlow(boards: Pick<BoardRegistry, 'get'>, item: Pick<Card, 'board'> | undefined): {
73
74
  flow?: FactoryRuleBoardFlow;
74
75
  };
75
- interface SourcedItem {
76
- readonly workItem?: {
77
- readonly sources?: readonly WorkItemSourceRow[];
78
- } | null;
79
- }
80
- /**
81
- * A card whose own primary source is a pull or merge request: an outside contributor's
82
- * PR filed on its own card, or a PR card filed before PRs attached to their issue's card.
83
- * An issue card with an attached PR is not one; see {@link hasPullRequest}.
84
- */
85
- export declare function isPullRequestCard(item: {
86
- readonly source: string;
87
- }): boolean;
88
- /** Every pull or merge request source on a card, oldest first. */
89
- export declare function pullRequestSources(item: SourcedItem): WorkItemSourceRow[];
90
76
  /** Whether a card carries a pull or merge request: its own, or one attached to its issue. */
91
77
  export declare function hasPullRequest(item: SourcedItem & {
92
78
  readonly source?: string;
93
79
  }): boolean;
94
- /** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
95
- export declare function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined;
96
- /**
97
- * The pull request a PR review pass on this card reviews: the one the card's
98
- * `openPullRequestNumber` names, else the newest open one, else the newest one.
99
- */
100
- export declare function reviewedPullRequest(item: SourcedItem & {
101
- readonly metadata?: Record<string, unknown> | null;
102
- }): WorkItemSourceRow | undefined;
103
- /** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */
104
- export declare function newestOpenPullRequestNumber(item: SourcedItem, except?: number): number | null;
105
80
  interface SessionedItem {
106
81
  readonly sessions: Readonly<Record<string, {
107
82
  readonly branch?: string | null;
@@ -116,8 +91,13 @@ type BranchedItem = Pick<Card, 'id' | 'externalSource'> & {
116
91
  * session is deleted).
117
92
  */
118
93
  export declare function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean;
119
- /** The newest open pull request the card's own sessions opened, other than `except`. */
120
- export declare function newestOwnedOpenPullRequestNumber(item: SourcedItem & SessionedItem & BranchedItem, except?: number): number | null;
94
+ /**
95
+ * The newest open pull request the card's own sessions opened, other than `except`. A branch name
96
+ * is anyone's to pick, so an outsider's pull request on the card's branch name never counts.
97
+ */
98
+ export declare function newestOwnedOpenPullRequestNumber(item: SourcedItem & SessionedItem & BranchedItem & {
99
+ readonly metadata?: Record<string, unknown> | null;
100
+ }, except?: number): number | null;
121
101
  /** The pull or merge request a card's PR review covers, whichever card shape carries it. */
122
102
  export interface ReviewedChangeRequest {
123
103
  readonly provider: 'github' | 'gitlab';
@@ -1 +1 @@
1
- {"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../../src/boards/semantics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAI3F,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAEf,cAAc,EACd,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAInE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,iFAAiF;IACjF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC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gBAAgB,GAAG,QAAQ,CAAC,GACtD,uBAAuB,GAAG,SAAS,CAUrC;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,YAAY,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG5C;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG9C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAU3G;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { workItemBranch, workItemBranchSource } from "../work-item-branch.js";
2
+ import { isOpenPullRequestSource, isPullRequestCard, pullRequestSourceNumber, pullRequestSources, reviewedPullRequest, trustedPullRequestSource } from "../work-items/change-requests.js";
2
3
  import "./default-board.js";
3
4
  import "./define-board.js";
4
5
  import { reviewBoard } from "./review.js";
@@ -123,46 +124,10 @@ function pullRequestCardRejection(board, card, toStage) {
123
124
  function withBoardFlow(boards, item) {
124
125
  return item ? { flow: cardBoardFlow(boards, item) } : {};
125
126
  }
126
- /**
127
- * A card whose own primary source is a pull or merge request: an outside contributor's
128
- * PR filed on its own card, or a PR card filed before PRs attached to their issue's card.
129
- * An issue card with an attached PR is not one; see {@link hasPullRequest}.
130
- */
131
- function isPullRequestCard(item) {
132
- return item.source === "github-pr" || item.source === "gitlab-pr";
133
- }
134
- /** Every pull or merge request source on a card, oldest first. */
135
- function pullRequestSources(item) {
136
- return (item.workItem?.sources ?? []).filter((source) => source.sourceType === "pull-request");
137
- }
138
127
  /** Whether a card carries a pull or merge request: its own, or one attached to its issue. */
139
128
  function hasPullRequest(item) {
140
129
  return item.source !== void 0 && isPullRequestCard({ source: item.source }) || pullRequestSources(item).length > 0;
141
130
  }
142
- /** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
143
- function pullRequestSourceNumber(source) {
144
- const metadata = source.metadata ?? {};
145
- const value = metadata.githubPullRequestNumber ?? metadata.gitlabMergeRequestIid ?? metadata.number;
146
- return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
147
- }
148
- function openSource(source) {
149
- const state = source.state ?? source.metadata?.state;
150
- return state !== "closed" && state !== "merged" && source.metadata?.merged !== true;
151
- }
152
- /**
153
- * The pull request a PR review pass on this card reviews: the one the card's
154
- * `openPullRequestNumber` names, else the newest open one, else the newest one.
155
- */
156
- function reviewedPullRequest(item) {
157
- const sources = pullRequestSources(item);
158
- const pointer = item.metadata?.openPullRequestNumber;
159
- return (typeof pointer === "number" ? sources.find((source) => pullRequestSourceNumber(source) === pointer) : void 0) ?? sources.findLast(openSource) ?? sources.at(-1);
160
- }
161
- /** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */
162
- function newestOpenPullRequestNumber(item, except) {
163
- const open = pullRequestSources(item).filter((source) => openSource(source) && pullRequestSourceNumber(source) !== except);
164
- return (open.length ? pullRequestSourceNumber(open.at(-1)) : void 0) ?? null;
165
- }
166
131
  /**
167
132
  * Whether a pull request from `headBranch` was opened by the card's own sessions: the head is
168
133
  * one of its session branches, or the branch Factory builds the card on (stable even after its
@@ -176,9 +141,12 @@ function cardOwnsBranch(item, headBranch) {
176
141
  metadata: item.workItem.metadata
177
142
  }) === headBranch || Object.values(item.sessions).some((session) => session?.branch === headBranch);
178
143
  }
179
- /** The newest open pull request the card's own sessions opened, other than `except`. */
144
+ /**
145
+ * The newest open pull request the card's own sessions opened, other than `except`. A branch name
146
+ * is anyone's to pick, so an outsider's pull request on the card's branch name never counts.
147
+ */
180
148
  function newestOwnedOpenPullRequestNumber(item, except) {
181
- const open = pullRequestSources(item).filter((source) => openSource(source) && pullRequestSourceNumber(source) !== except && typeof source.metadata?.headBranch === "string" && cardOwnsBranch(item, source.metadata.headBranch));
149
+ const open = pullRequestSources(item).filter((source) => isOpenPullRequestSource(source) && pullRequestSourceNumber(source) !== except && trustedPullRequestSource(item, source) && typeof source.metadata?.headBranch === "string" && cardOwnsBranch(item, source.metadata.headBranch));
182
150
  return (open.length ? pullRequestSourceNumber(open.at(-1)) : void 0) ?? null;
183
151
  }
184
152
  /**
@@ -365,6 +333,6 @@ function boundChangeRequestNumber(boards, item) {
365
333
  if (number !== void 0) return String(number);
366
334
  return source === "github-pr" ? /(\d+)$/.exec(item.externalSource?.externalId ?? "")?.[1] : void 0;
367
335
  }
368
- export { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, hasRecordedVerdict, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestCardRejection, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workItemPhaseSemantics };
336
+ export { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, hasRecordedVerdict, intakeTarget, isPullRequestReviewPhase, isTerminalWorkItem, newestOwnedOpenPullRequestNumber, pullRequestCardRejection, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workItemPhaseSemantics };
369
337
 
370
338
  //# sourceMappingURL=semantics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantics.js","names":[],"sources":["../../src/boards/semantics.ts"],"sourcesContent":["import type {\n FactoryRuleBoardClosure,\n FactoryRuleBoardFlow,\n FactoryRuleIntakeTarget,\n FactoryRulePhaseContext,\n} from '../rules/types.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport type { MetricsPhaseOutcomes } from '../storage/domains/work-items/metrics.js';\nimport type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\nimport { workItemBranch, workItemBranchSource } from '../work-item-branch.js';\nimport { DEFAULT_BOARD_ID } from './default-board.js';\nimport { REVIEW_CONTEXT } from './define-board.js';\nimport type {\n BoardEventIntegration,\n BoardEventRules,\n BoardPhase,\n BoardPhaseKind,\n BoardToolResultRuleHandler,\n} from './define-board.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { workBoard } from './work.js';\n\nexport interface PhaseSemantics {\n readonly kind: BoardPhaseKind;\n /** Seat that carries a working phase; absent for resting and terminal phases. */\n readonly role?: string;\n}\n\n/**\n * Board that owns a work item. Rows created before boards were persisted carry no `board`;\n * they belong to the default board. (Pull requests used to default to the retired Review board;\n * storage reads those rows as the default board, and keeps cards stored on Review there only in a\n * project that still uses it.)\n */\nexport function boardForWorkItem(item: Pick<Card, 'board'>): string {\n return item.board ?? DEFAULT_BOARD_ID;\n}\n\nconst flows = new WeakMap<object, FactoryRuleBoardFlow>();\n\n/**\n * The phases a board's pull request loop runs through, read from what each phase declares\n * rather than from its key:\n *\n * Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat\n * that records verdicts.\n *\n * - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull\n * requests: a pull request's own card is reviewed there, an attached pull request is reviewed\n * there, verdicts on pull requests are recorded there, and a push or review request re-enters it.\n * - `selfReview`: the first working phase that grants `factory_record_review_verdict` without\n * `factory_review_source`: an independent review of the builder's branch before a pull request.\n * - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs\n * in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that\n * builds nothing has no triage phase.\n * - `build`: the last working phase, in declaration order, that is neither of those and can move\n * into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends\n * requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.\n *\n * A board without a `factory_review_source` phase has no pull request loop.\n */\nexport function boardFlow(board: InstalledBoard | undefined): FactoryRuleBoardFlow {\n if (!board) return Object.freeze({});\n const cached = flows.get(board);\n if (cached) return cached;\n const entries = Object.entries(board.phases) as [string, BoardPhase<string>][];\n const grants = (phase: BoardPhase<string>, tool: string) =>\n phase.kind === 'working' &&\n phase.runner.context === REVIEW_CONTEXT &&\n (phase.tools ?? []).some(granted => granted === tool);\n const pullRequestReview = entries.find(([, phase]) => grants(phase, 'factory_review_source'))?.[0];\n const selfReview = entries.find(\n ([key, phase]) =>\n key !== pullRequestReview &&\n grants(phase, 'factory_record_review_verdict') &&\n !grants(phase, 'factory_review_source'),\n )?.[0];\n const handoff = selfReview ?? pullRequestReview;\n const build = handoff\n ? entries.findLast(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== pullRequestReview &&\n key !== selfReview &&\n board.allowsTransition(key, handoff),\n )?.[0]\n : undefined;\n const buildRole = build ? board.roleForPhase(build) : undefined;\n // Only a board that builds sorts cards first; elsewhere a working phase is just its own step.\n const triage = build\n ? entries.find(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== build &&\n phase.runner.context !== REVIEW_CONTEXT &&\n phase.runner.context !== buildRole,\n )?.[0]\n : undefined;\n const terminals = entries.filter(([, phase]) => phase.kind === 'terminal').map(([key]) => key);\n const completed = board.sourceClosed?.completed ?? terminals[0];\n const canceled = board.sourceClosed?.canceled ?? terminals.find(key => key !== completed) ?? completed;\n const ref = (phase: string) => Object.freeze({ phase, title: board.phases[phase]!.name });\n const flow = Object.freeze({\n initialPhase: board.initialPhase,\n ...(completed ? { completed: ref(completed) } : {}),\n ...(canceled ? { canceled: ref(canceled) } : {}),\n ...(triage ? { triage } : {}),\n ...(pullRequestReview ? { pullRequestReview } : {}),\n ...(selfReview ? { selfReview } : {}),\n ...(build ? { build } : {}),\n ...(buildRole ? { buildRole } : {}),\n });\n flows.set(board, flow);\n return flow;\n}\n\n/**\n * Where integrations file new items, and where one lands when no intake route takes it: the\n * project's Work board's initial phase, else (a project an app gave only its own boards) the\n * initial phase of its first board in catalog order. Undefined only for a project with no boards.\n */\nexport function intakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): FactoryRuleIntakeTarget | undefined {\n const target = boards.get(DEFAULT_BOARD_ID) ?? boards.values().next().value;\n if (!target) return undefined;\n return Object.freeze({ board: target.id, initialPhase: target.initialPhase });\n}\n\n/** {@link intakeTarget} as a rule context field. */\nexport function withIntakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): { intake?: FactoryRuleIntakeTarget } {\n const intake = intakeTarget(boards);\n return intake ? { intake } : {};\n}\n\n/** {@link boardFlow} of the board a card sits on. */\nexport function cardBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): FactoryRuleBoardFlow {\n return item ? boardFlow(boards.get(boardForWorkItem(item))) : Object.freeze({});\n}\n\n/**\n * Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being\n * triaged. Approval labels hold only such cards.\n */\nexport function awaitsAcceptance(board: InstalledBoard | undefined, stage: string): boolean {\n if (!board) return false;\n return board.phaseKind(stage) === 'resting' || stage === boardFlow(board).triage;\n}\n\n/** Whether `stage` is the phase where the board reviews pull requests. */\nexport function isPullRequestReviewPhase(board: InstalledBoard | undefined, stage: string | undefined): boolean {\n const phase = boardFlow(board).pullRequestReview;\n return phase !== undefined && phase === stage;\n}\n\n/**\n * Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it\n * does not: a pull request's own card is only reviewed, so it enters no other working phase, and\n * the pull request review phase holds only cards that carry a pull request (their own, or one\n * attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and\n * which one fits depends on the card.\n */\nexport function pullRequestCardRejection(\n board: InstalledBoard,\n card: { readonly standalonePullRequest: boolean; readonly hasPullRequest: boolean },\n toStage: string,\n): string | undefined {\n const review = boardFlow(board).pullRequestReview;\n if (!review) return undefined;\n const reviewName = board.phases[review]?.name ?? review;\n if (!card.hasPullRequest && toStage === review) {\n return `${reviewName} holds only cards with a pull request; this work item enters it once a pull request is attached to it.`;\n }\n if (!card.standalonePullRequest || toStage === review || !board.isWorking(toStage)) return undefined;\n const exits = [review, ...Object.keys(board.phases).filter(key => board.isTerminal(key))];\n return `A pull request card is only reviewed on the ${board.name} board; it cannot enter ${toStage}. Move it to ${exits.join(', ')}.`;\n}\n\n/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */\nexport function withBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): { flow?: FactoryRuleBoardFlow } {\n return item ? { flow: cardBoardFlow(boards, item) } : {};\n}\n\ninterface SourcedItem {\n readonly workItem?: { readonly sources?: readonly WorkItemSourceRow[] } | null;\n}\n\n/**\n * A card whose own primary source is a pull or merge request: an outside contributor's\n * PR filed on its own card, or a PR card filed before PRs attached to their issue's card.\n * An issue card with an attached PR is not one; see {@link hasPullRequest}.\n */\nexport function isPullRequestCard(item: { readonly source: string }): boolean {\n return item.source === 'github-pr' || item.source === 'gitlab-pr';\n}\n\n/** Every pull or merge request source on a card, oldest first. */\nexport function pullRequestSources(item: SourcedItem): WorkItemSourceRow[] {\n return (item.workItem?.sources ?? []).filter(source => source.sourceType === 'pull-request');\n}\n\n/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */\nexport function hasPullRequest(item: SourcedItem & { readonly source?: string }): boolean {\n return (\n (item.source !== undefined && isPullRequestCard({ source: item.source })) || pullRequestSources(item).length > 0\n );\n}\n\n/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */\nexport function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined {\n const metadata = source.metadata ?? {};\n const value = metadata.githubPullRequestNumber ?? metadata.gitlabMergeRequestIid ?? metadata.number;\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\nfunction openSource(source: Pick<WorkItemSourceRow, 'state' | 'metadata'>): boolean {\n const state = source.state ?? source.metadata?.state;\n return state !== 'closed' && state !== 'merged' && source.metadata?.merged !== true;\n}\n\n/**\n * The pull request a PR review pass on this card reviews: the one the card's\n * `openPullRequestNumber` names, else the newest open one, else the newest one.\n */\nexport function reviewedPullRequest(\n item: SourcedItem & { readonly metadata?: Record<string, unknown> | null },\n): WorkItemSourceRow | undefined {\n const sources = pullRequestSources(item);\n const pointer = item.metadata?.openPullRequestNumber;\n return (\n (typeof pointer === 'number' ? sources.find(source => pullRequestSourceNumber(source) === pointer) : undefined) ??\n sources.findLast(openSource) ??\n sources.at(-1)\n );\n}\n\n/** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */\nexport function newestOpenPullRequestNumber(item: SourcedItem, except?: number): number | null {\n const open = pullRequestSources(item).filter(\n source => openSource(source) && pullRequestSourceNumber(source) !== except,\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\ninterface SessionedItem {\n readonly sessions: Readonly<Record<string, { readonly branch?: string | null } | undefined>>;\n}\n\ntype BranchedItem = Pick<Card, 'id' | 'externalSource'> & { readonly workItem: Pick<Card['workItem'], 'metadata'> };\n\n/**\n * Whether a pull request from `headBranch` was opened by the card's own sessions: the head is\n * one of its session branches, or the branch Factory builds the card on (stable even after its\n * session is deleted).\n */\nexport function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean {\n if (!headBranch) return false;\n const buildBranch = workItemBranch({\n id: item.id,\n source: workItemBranchSource(item.externalSource),\n metadata: item.workItem.metadata,\n });\n return buildBranch === headBranch || Object.values(item.sessions).some(session => session?.branch === headBranch);\n}\n\n/** The newest open pull request the card's own sessions opened, other than `except`. */\nexport function newestOwnedOpenPullRequestNumber(\n item: SourcedItem & SessionedItem & BranchedItem,\n except?: number,\n): number | null {\n const open = pullRequestSources(item).filter(\n source =>\n openSource(source) &&\n pullRequestSourceNumber(source) !== except &&\n typeof source.metadata?.headBranch === 'string' &&\n cardOwnsBranch(item, source.metadata.headBranch),\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\n/** The pull or merge request a card's PR review covers, whichever card shape carries it. */\nexport interface ReviewedChangeRequest {\n readonly provider: 'github' | 'gitlab';\n readonly number: number | undefined;\n readonly url: string | null;\n readonly headBranch: string | undefined;\n /** The card is the change request's own card rather than an issue card it is attached to. */\n readonly standalone: boolean;\n}\n\n/**\n * What a PR review on this card reviews: the card's own change request when the card is one,\n * otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.\n */\nexport function reviewedChangeRequest(item: {\n readonly source: string;\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly workItem: {\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly sources?: readonly WorkItemSourceRow[];\n };\n}): ReviewedChangeRequest | undefined {\n if (isPullRequestCard(item)) {\n const metadata = item.workItem.metadata ?? {};\n const gitlab = item.source === 'gitlab-pr';\n const value = (gitlab ? metadata.gitlabMergeRequestIid : metadata.githubPullRequestNumber) ?? metadata.number;\n return {\n provider: gitlab ? 'gitlab' : 'github',\n number: typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined,\n url: item.url ?? item.workItem.url ?? null,\n headBranch: typeof metadata.headBranch === 'string' ? metadata.headBranch : undefined,\n standalone: true,\n };\n }\n const source = reviewedPullRequest(item);\n if (!source) return undefined;\n return {\n provider: source.integrationId === 'gitlab' ? 'gitlab' : 'github',\n number: pullRequestSourceNumber(source),\n url: source.url ?? null,\n headBranch: typeof source.metadata?.headBranch === 'string' ? source.metadata.headBranch : undefined,\n standalone: false,\n };\n}\n\n/**\n * Whether a pass already recorded a verdict on `change`. An issue card can carry\n * several pull requests, so a verdict stamped for another one doesn't count; a\n * verdict with no number (a standalone card, or one stamped before verdicts named\n * their pull request) covers the card.\n */\nexport function hasRecordedVerdict(\n item: Parameters<typeof reviewedChangeRequest>[0],\n change: Pick<ReviewedChangeRequest, 'number'> | undefined = reviewedChangeRequest(item),\n): boolean {\n const covered = item.metadata?.reviewedPullRequestNumber;\n const reviewedAnother = typeof covered === 'number' && change?.number !== undefined && covered !== change.number;\n return typeof item.metadata?.reviewVerdict === 'string' && !reviewedAnother;\n}\n\n/**\n * Whether the rule's card carries a change request its board reviews: the card has one, and its\n * board has a phase that takes pull requests ({@link boardFlow}).\n */\nexport function reviewsPullRequest(context: {\n readonly flow?: Pick<FactoryRuleBoardFlow, 'pullRequestReview'>;\n readonly item?: SourcedItem & { readonly source: string };\n}): boolean {\n return context.flow?.pullRequestReview !== undefined && context.item !== undefined && hasPullRequest(context.item);\n}\n\n/**\n * What the installed board says `phase` means. Returns undefined when the board is not\n * installed or does not declare the phase; callers must fail closed on undefined rather\n * than guess from the phase name.\n */\nexport function resolvePhaseSemantics(\n boards: BoardRegistry,\n boardId: string,\n phase: string,\n): PhaseSemantics | undefined {\n const board = boards.get(boardId);\n const kind = board?.phaseKind(phase);\n if (!board || !kind) return undefined;\n const role = board.roleForPhase(phase);\n return role === undefined ? { kind } : { kind, role };\n}\n\n/**\n * Tool-result rule the installed board declares for `toolName`. Undefined when the board is\n * not installed or declares no rule for the tool; callers must run nothing in that case.\n */\nexport function resolveBoardToolRule(\n boards: BoardRegistry,\n boardId: string,\n toolName: string,\n): BoardToolResultRuleHandler | undefined {\n return boards.get(boardId)?.tools[toolName]?.onResult;\n}\n\n/**\n * Integration event handlers the installed board declares for cards on it, or undefined when the\n * card is unbound, the board is not installed, or it declares none for this integration. Within the\n * map, `null` means the board switched that event off for its cards.\n */\nexport function boardEventHandlers<I extends BoardEventIntegration>(\n boards: Pick<BoardRegistry, 'get'>,\n boardId: string | undefined,\n integration: I,\n): BoardEventRules[I] | undefined {\n return boardId === undefined ? undefined : boards.get(boardId)?.events[integration];\n}\n\n/**\n * Board whose event handlers answer an integration evaluation: the bound card's board, except on\n * the evaluation that files a pull request's own Review card, which is about a card that does\n * not exist yet.\n */\nexport function eventBoardId(context: {\n readonly item?: unknown;\n readonly board?: string;\n readonly pullRequestIntake?: boolean;\n}): string | undefined {\n return context.item && !context.pullRequestIntake ? context.board : undefined;\n}\n\n/** What a card's single current phase means on its installed board, for integration rule contexts. */\nexport function rulePhaseContext(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRulePhaseContext | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || !kind) return undefined;\n const context = board.roleForPhase(stage);\n const phase = board.phases[stage];\n return Object.freeze({\n id: stage,\n kind,\n ...(context === undefined ? {} : { context, role: context }),\n nextPhases: Object.freeze([...(phase?.nextPhases ?? [])]),\n });\n}\n\n/**\n * Whether a persisted card has finished, judged by the board it sits on: the installed board's\n * phase kind first, then, for rows whose board is not installed, the phase kinds of the default\n * board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,\n * so a card is only ever released from ownership on the board's own say-so.\n */\nexport function isTerminalWorkItem(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): boolean {\n const semantics = workItemPhaseSemantics(boards, item);\n if (semantics) return semantics.kind === 'terminal';\n const board = boardForWorkItem(item);\n if (boards.has(board)) return false;\n const seed = board === DEFAULT_BOARD_ID ? workBoard : board === reviewBoard.id ? reviewBoard : undefined;\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n return stage !== undefined && seed !== undefined && seed.isTerminal(stage);\n}\n\n/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */\nexport function workItemPhaseSemantics(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): PhaseSemantics | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n return resolvePhaseSemantics(boards, boardForWorkItem(item), stage);\n}\n\n/**\n * Flow-metric outcomes of each board's phases: the phase the board closes completed sources into\n * (else its first terminal phase) completes a card, other terminal phases cancel it, resting\n * phases queue it, and anything else (working, or a phase the board no longer declares) is in\n * flight.\n */\nexport function boardPhaseOutcomes(boards: Pick<BoardRegistry, 'get'>): MetricsPhaseOutcomes {\n return (item, stage) => {\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || kind === undefined || kind === 'working') return 'pipeline';\n if (kind === 'resting') return 'queued';\n const completed = board.sourceClosed?.completed ?? Object.keys(board.phases).find(key => board.isTerminal(key));\n return stage === completed ? 'completed' : 'canceled';\n };\n}\n\n/**\n * Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed\n * board declares, plus whether the card already sits in a terminal phase. Undefined when the\n * board is not installed or declares no mapping, so closing the source leaves the card alone.\n */\nexport function resolveBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRuleBoardClosure | undefined {\n const board = boards.get(boardForWorkItem(item));\n if (!board?.sourceClosed) return undefined;\n const { completed, canceled } = board.sourceClosed;\n return {\n boardTitle: board.name,\n completed: { phase: completed, title: board.phases[completed]!.name },\n canceled: { phase: canceled, title: board.phases[canceled]!.name },\n itemTerminal: item.stages.some(stage => board.isTerminal(stage)),\n };\n}\n\n/** Rule-context fragment carrying the card's `boardClosure`, empty when the board declares none. */\nexport function withBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { boardClosure?: FactoryRuleBoardClosure } {\n const boardClosure = resolveBoardClosure(boards, item);\n return boardClosure ? { boardClosure } : {};\n}\n\n/** `{ phase }` for spreading into an integration rule context, or `{}` when the phase is unknown. */\nexport function rulePhaseField(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { readonly phase?: FactoryRulePhaseContext } {\n const phase = rulePhaseContext(boards, item);\n return phase ? { phase } : {};\n}\n\n/**\n * The change request a review session on this card may publish checks for: the card's own one,\n * or, for an issue card in its board's pull request review phase, the pull request attached to it.\n */\nexport function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined {\n const source = workItemBranchSource(item.externalSource);\n const own = isPullRequestCard({ source });\n if (!own && (item.stages.length !== 1 || cardBoardFlow(boards, item).pullRequestReview !== item.stages[0])) {\n return undefined;\n }\n const number = reviewedChangeRequest({ ...item, source })?.number;\n if (number !== undefined) return String(number);\n // A GitHub key ends in its number (`github-pr:34`); a GitLab key is encoded, so its digits mean nothing.\n return source === 'github-pr' ? /(\\d+)$/.exec(item.externalSource?.externalId ?? '')?.[1] : undefined;\n}\n\nexport { sourceExternalId } from '../work-items/source-external-id.js';\n"],"mappings":";;;;;;;;;;;;;AAmCA,SAAgB,iBAAiB,MAAmC;CAClE,OAAO,KAAK,SAAA;AACd;AAEA,MAAM,wBAAQ,IAAI,QAAsC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,SAAgB,UAAU,OAAyD;CACjF,IAAI,CAAC,OAAO,OAAO,OAAO,OAAO,CAAC,CAAC;CACnC,MAAM,SAAS,MAAM,IAAI,KAAK;CAC9B,IAAI,QAAQ,OAAO;CACnB,MAAM,UAAU,OAAO,QAAQ,MAAM,MAAM;CAC3C,MAAM,UAAU,OAA2B,SACzC,MAAM,SAAS,aACf,MAAM,OAAO,YAAA,aACZ,MAAM,SAAS,CAAC,EAAA,CAAG,MAAK,YAAW,YAAY,IAAI;CACtD,MAAM,oBAAoB,QAAQ,M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,KAAK,KAAA;AAC9F"}
1
+ {"version":3,"file":"semantics.js","names":[],"sources":["../../src/boards/semantics.ts"],"sourcesContent":["import type {\n FactoryRuleBoardClosure,\n FactoryRuleBoardFlow,\n FactoryRuleIntakeTarget,\n FactoryRulePhaseContext,\n} from '../rules/types.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport type { MetricsPhaseOutcomes } from '../storage/domains/work-items/metrics.js';\nimport type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\nimport { workItemBranch, workItemBranchSource } from '../work-item-branch.js';\nimport {\n isOpenPullRequestSource,\n isPullRequestCard,\n pullRequestSourceNumber,\n pullRequestSources,\n reviewedPullRequest,\n trustedPullRequestSource,\n} from '../work-items/change-requests.js';\nimport type { SourcedItem } from '../work-items/change-requests.js';\nimport { DEFAULT_BOARD_ID } from './default-board.js';\nimport { REVIEW_CONTEXT } from './define-board.js';\nimport type {\n BoardEventIntegration,\n BoardEventRules,\n BoardPhase,\n BoardPhaseKind,\n BoardToolResultRuleHandler,\n} from './define-board.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { workBoard } from './work.js';\n\nexport interface PhaseSemantics {\n readonly kind: BoardPhaseKind;\n /** Seat that carries a working phase; absent for resting and terminal phases. */\n readonly role?: string;\n}\n\n/**\n * Board that owns a work item. Rows created before boards were persisted carry no `board`;\n * they belong to the default board. (Pull requests used to default to the retired Review board;\n * storage reads those rows as the default board, and keeps cards stored on Review there only in a\n * project that still uses it.)\n */\nexport function boardForWorkItem(item: Pick<Card, 'board'>): string {\n return item.board ?? DEFAULT_BOARD_ID;\n}\n\nconst flows = new WeakMap<object, FactoryRuleBoardFlow>();\n\n/**\n * The phases a board's pull request loop runs through, read from what each phase declares\n * rather than from its key:\n *\n * Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat\n * that records verdicts.\n *\n * - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull\n * requests: a pull request's own card is reviewed there, an attached pull request is reviewed\n * there, verdicts on pull requests are recorded there, and a push or review request re-enters it.\n * - `selfReview`: the first working phase that grants `factory_record_review_verdict` without\n * `factory_review_source`: an independent review of the builder's branch before a pull request.\n * - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs\n * in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that\n * builds nothing has no triage phase.\n * - `build`: the last working phase, in declaration order, that is neither of those and can move\n * into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends\n * requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.\n *\n * A board without a `factory_review_source` phase has no pull request loop.\n */\nexport function boardFlow(board: InstalledBoard | undefined): FactoryRuleBoardFlow {\n if (!board) return Object.freeze({});\n const cached = flows.get(board);\n if (cached) return cached;\n const entries = Object.entries(board.phases) as [string, BoardPhase<string>][];\n const grants = (phase: BoardPhase<string>, tool: string) =>\n phase.kind === 'working' &&\n phase.runner.context === REVIEW_CONTEXT &&\n (phase.tools ?? []).some(granted => granted === tool);\n const pullRequestReview = entries.find(([, phase]) => grants(phase, 'factory_review_source'))?.[0];\n const selfReview = entries.find(\n ([key, phase]) =>\n key !== pullRequestReview &&\n grants(phase, 'factory_record_review_verdict') &&\n !grants(phase, 'factory_review_source'),\n )?.[0];\n const handoff = selfReview ?? pullRequestReview;\n const build = handoff\n ? entries.findLast(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== pullRequestReview &&\n key !== selfReview &&\n board.allowsTransition(key, handoff),\n )?.[0]\n : undefined;\n const buildRole = build ? board.roleForPhase(build) : undefined;\n // Only a board that builds sorts cards first; elsewhere a working phase is just its own step.\n const triage = build\n ? entries.find(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== build &&\n phase.runner.context !== REVIEW_CONTEXT &&\n phase.runner.context !== buildRole,\n )?.[0]\n : undefined;\n const terminals = entries.filter(([, phase]) => phase.kind === 'terminal').map(([key]) => key);\n const completed = board.sourceClosed?.completed ?? terminals[0];\n const canceled = board.sourceClosed?.canceled ?? terminals.find(key => key !== completed) ?? completed;\n const ref = (phase: string) => Object.freeze({ phase, title: board.phases[phase]!.name });\n const flow = Object.freeze({\n initialPhase: board.initialPhase,\n ...(completed ? { completed: ref(completed) } : {}),\n ...(canceled ? { canceled: ref(canceled) } : {}),\n ...(triage ? { triage } : {}),\n ...(pullRequestReview ? { pullRequestReview } : {}),\n ...(selfReview ? { selfReview } : {}),\n ...(build ? { build } : {}),\n ...(buildRole ? { buildRole } : {}),\n });\n flows.set(board, flow);\n return flow;\n}\n\n/**\n * Where integrations file new items, and where one lands when no intake route takes it: the\n * project's Work board's initial phase, else (a project an app gave only its own boards) the\n * initial phase of its first board in catalog order. Undefined only for a project with no boards.\n */\nexport function intakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): FactoryRuleIntakeTarget | undefined {\n const target = boards.get(DEFAULT_BOARD_ID) ?? boards.values().next().value;\n if (!target) return undefined;\n return Object.freeze({ board: target.id, initialPhase: target.initialPhase });\n}\n\n/** {@link intakeTarget} as a rule context field. */\nexport function withIntakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): { intake?: FactoryRuleIntakeTarget } {\n const intake = intakeTarget(boards);\n return intake ? { intake } : {};\n}\n\n/** {@link boardFlow} of the board a card sits on. */\nexport function cardBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): FactoryRuleBoardFlow {\n return item ? boardFlow(boards.get(boardForWorkItem(item))) : Object.freeze({});\n}\n\n/**\n * Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being\n * triaged. Approval labels hold only such cards.\n */\nexport function awaitsAcceptance(board: InstalledBoard | undefined, stage: string): boolean {\n if (!board) return false;\n return board.phaseKind(stage) === 'resting' || stage === boardFlow(board).triage;\n}\n\n/** Whether `stage` is the phase where the board reviews pull requests. */\nexport function isPullRequestReviewPhase(board: InstalledBoard | undefined, stage: string | undefined): boolean {\n const phase = boardFlow(board).pullRequestReview;\n return phase !== undefined && phase === stage;\n}\n\n/**\n * Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it\n * does not: a pull request's own card is only reviewed, so it enters no other working phase, and\n * the pull request review phase holds only cards that carry a pull request (their own, or one\n * attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and\n * which one fits depends on the card.\n */\nexport function pullRequestCardRejection(\n board: InstalledBoard,\n card: { readonly standalonePullRequest: boolean; readonly hasPullRequest: boolean },\n toStage: string,\n): string | undefined {\n const review = boardFlow(board).pullRequestReview;\n if (!review) return undefined;\n const reviewName = board.phases[review]?.name ?? review;\n if (!card.hasPullRequest && toStage === review) {\n return `${reviewName} holds only cards with a pull request; this work item enters it once a pull request is attached to it.`;\n }\n if (!card.standalonePullRequest || toStage === review || !board.isWorking(toStage)) return undefined;\n const exits = [review, ...Object.keys(board.phases).filter(key => board.isTerminal(key))];\n return `A pull request card is only reviewed on the ${board.name} board; it cannot enter ${toStage}. Move it to ${exits.join(', ')}.`;\n}\n\n/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */\nexport function withBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): { flow?: FactoryRuleBoardFlow } {\n return item ? { flow: cardBoardFlow(boards, item) } : {};\n}\n\n/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */\nexport function hasPullRequest(item: SourcedItem & { readonly source?: string }): boolean {\n return (\n (item.source !== undefined && isPullRequestCard({ source: item.source })) || pullRequestSources(item).length > 0\n );\n}\n\ninterface SessionedItem {\n readonly sessions: Readonly<Record<string, { readonly branch?: string | null } | undefined>>;\n}\n\ntype BranchedItem = Pick<Card, 'id' | 'externalSource'> & { readonly workItem: Pick<Card['workItem'], 'metadata'> };\n\n/**\n * Whether a pull request from `headBranch` was opened by the card's own sessions: the head is\n * one of its session branches, or the branch Factory builds the card on (stable even after its\n * session is deleted).\n */\nexport function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean {\n if (!headBranch) return false;\n const buildBranch = workItemBranch({\n id: item.id,\n source: workItemBranchSource(item.externalSource),\n metadata: item.workItem.metadata,\n });\n return buildBranch === headBranch || Object.values(item.sessions).some(session => session?.branch === headBranch);\n}\n\n/**\n * The newest open pull request the card's own sessions opened, other than `except`. A branch name\n * is anyone's to pick, so an outsider's pull request on the card's branch name never counts.\n */\nexport function newestOwnedOpenPullRequestNumber(\n item: SourcedItem & SessionedItem & BranchedItem & { readonly metadata?: Record<string, unknown> | null },\n except?: number,\n): number | null {\n const open = pullRequestSources(item).filter(\n source =>\n isOpenPullRequestSource(source) &&\n pullRequestSourceNumber(source) !== except &&\n trustedPullRequestSource(item, source) &&\n typeof source.metadata?.headBranch === 'string' &&\n cardOwnsBranch(item, source.metadata.headBranch),\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\n/** The pull or merge request a card's PR review covers, whichever card shape carries it. */\nexport interface ReviewedChangeRequest {\n readonly provider: 'github' | 'gitlab';\n readonly number: number | undefined;\n readonly url: string | null;\n readonly headBranch: string | undefined;\n /** The card is the change request's own card rather than an issue card it is attached to. */\n readonly standalone: boolean;\n}\n\n/**\n * What a PR review on this card reviews: the card's own change request when the card is one,\n * otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.\n */\nexport function reviewedChangeRequest(item: {\n readonly source: string;\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly workItem: {\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly sources?: readonly WorkItemSourceRow[];\n };\n}): ReviewedChangeRequest | undefined {\n if (isPullRequestCard(item)) {\n const metadata = item.workItem.metadata ?? {};\n const gitlab = item.source === 'gitlab-pr';\n const value = (gitlab ? metadata.gitlabMergeRequestIid : metadata.githubPullRequestNumber) ?? metadata.number;\n return {\n provider: gitlab ? 'gitlab' : 'github',\n number: typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined,\n url: item.url ?? item.workItem.url ?? null,\n headBranch: typeof metadata.headBranch === 'string' ? metadata.headBranch : undefined,\n standalone: true,\n };\n }\n const source = reviewedPullRequest(item);\n if (!source) return undefined;\n return {\n provider: source.integrationId === 'gitlab' ? 'gitlab' : 'github',\n number: pullRequestSourceNumber(source),\n url: source.url ?? null,\n headBranch: typeof source.metadata?.headBranch === 'string' ? source.metadata.headBranch : undefined,\n standalone: false,\n };\n}\n\n/**\n * Whether a pass already recorded a verdict on `change`. An issue card can carry\n * several pull requests, so a verdict stamped for another one doesn't count; a\n * verdict with no number (a standalone card, or one stamped before verdicts named\n * their pull request) covers the card.\n */\nexport function hasRecordedVerdict(\n item: Parameters<typeof reviewedChangeRequest>[0],\n change: Pick<ReviewedChangeRequest, 'number'> | undefined = reviewedChangeRequest(item),\n): boolean {\n const covered = item.metadata?.reviewedPullRequestNumber;\n const reviewedAnother = typeof covered === 'number' && change?.number !== undefined && covered !== change.number;\n return typeof item.metadata?.reviewVerdict === 'string' && !reviewedAnother;\n}\n\n/**\n * Whether the rule's card carries a change request its board reviews: the card has one, and its\n * board has a phase that takes pull requests ({@link boardFlow}).\n */\nexport function reviewsPullRequest(context: {\n readonly flow?: Pick<FactoryRuleBoardFlow, 'pullRequestReview'>;\n readonly item?: SourcedItem & { readonly source: string };\n}): boolean {\n return context.flow?.pullRequestReview !== undefined && context.item !== undefined && hasPullRequest(context.item);\n}\n\n/**\n * What the installed board says `phase` means. Returns undefined when the board is not\n * installed or does not declare the phase; callers must fail closed on undefined rather\n * than guess from the phase name.\n */\nexport function resolvePhaseSemantics(\n boards: BoardRegistry,\n boardId: string,\n phase: string,\n): PhaseSemantics | undefined {\n const board = boards.get(boardId);\n const kind = board?.phaseKind(phase);\n if (!board || !kind) return undefined;\n const role = board.roleForPhase(phase);\n return role === undefined ? { kind } : { kind, role };\n}\n\n/**\n * Tool-result rule the installed board declares for `toolName`. Undefined when the board is\n * not installed or declares no rule for the tool; callers must run nothing in that case.\n */\nexport function resolveBoardToolRule(\n boards: BoardRegistry,\n boardId: string,\n toolName: string,\n): BoardToolResultRuleHandler | undefined {\n return boards.get(boardId)?.tools[toolName]?.onResult;\n}\n\n/**\n * Integration event handlers the installed board declares for cards on it, or undefined when the\n * card is unbound, the board is not installed, or it declares none for this integration. Within the\n * map, `null` means the board switched that event off for its cards.\n */\nexport function boardEventHandlers<I extends BoardEventIntegration>(\n boards: Pick<BoardRegistry, 'get'>,\n boardId: string | undefined,\n integration: I,\n): BoardEventRules[I] | undefined {\n return boardId === undefined ? undefined : boards.get(boardId)?.events[integration];\n}\n\n/**\n * Board whose event handlers answer an integration evaluation: the bound card's board, except on\n * the evaluation that files a pull request's own Review card, which is about a card that does\n * not exist yet.\n */\nexport function eventBoardId(context: {\n readonly item?: unknown;\n readonly board?: string;\n readonly pullRequestIntake?: boolean;\n}): string | undefined {\n return context.item && !context.pullRequestIntake ? context.board : undefined;\n}\n\n/** What a card's single current phase means on its installed board, for integration rule contexts. */\nexport function rulePhaseContext(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRulePhaseContext | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || !kind) return undefined;\n const context = board.roleForPhase(stage);\n const phase = board.phases[stage];\n return Object.freeze({\n id: stage,\n kind,\n ...(context === undefined ? {} : { context, role: context }),\n nextPhases: Object.freeze([...(phase?.nextPhases ?? [])]),\n });\n}\n\n/**\n * Whether a persisted card has finished, judged by the board it sits on: the installed board's\n * phase kind first, then, for rows whose board is not installed, the phase kinds of the default\n * board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,\n * so a card is only ever released from ownership on the board's own say-so.\n */\nexport function isTerminalWorkItem(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): boolean {\n const semantics = workItemPhaseSemantics(boards, item);\n if (semantics) return semantics.kind === 'terminal';\n const board = boardForWorkItem(item);\n if (boards.has(board)) return false;\n const seed = board === DEFAULT_BOARD_ID ? workBoard : board === reviewBoard.id ? reviewBoard : undefined;\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n return stage !== undefined && seed !== undefined && seed.isTerminal(stage);\n}\n\n/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */\nexport function workItemPhaseSemantics(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): PhaseSemantics | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n return resolvePhaseSemantics(boards, boardForWorkItem(item), stage);\n}\n\n/**\n * Flow-metric outcomes of each board's phases: the phase the board closes completed sources into\n * (else its first terminal phase) completes a card, other terminal phases cancel it, resting\n * phases queue it, and anything else (working, or a phase the board no longer declares) is in\n * flight.\n */\nexport function boardPhaseOutcomes(boards: Pick<BoardRegistry, 'get'>): MetricsPhaseOutcomes {\n return (item, stage) => {\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || kind === undefined || kind === 'working') return 'pipeline';\n if (kind === 'resting') return 'queued';\n const completed = board.sourceClosed?.completed ?? Object.keys(board.phases).find(key => board.isTerminal(key));\n return stage === completed ? 'completed' : 'canceled';\n };\n}\n\n/**\n * Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed\n * board declares, plus whether the card already sits in a terminal phase. Undefined when the\n * board is not installed or declares no mapping, so closing the source leaves the card alone.\n */\nexport function resolveBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRuleBoardClosure | undefined {\n const board = boards.get(boardForWorkItem(item));\n if (!board?.sourceClosed) return undefined;\n const { completed, canceled } = board.sourceClosed;\n return {\n boardTitle: board.name,\n completed: { phase: completed, title: board.phases[completed]!.name },\n canceled: { phase: canceled, title: board.phases[canceled]!.name },\n itemTerminal: item.stages.some(stage => board.isTerminal(stage)),\n };\n}\n\n/** Rule-context fragment carrying the card's `boardClosure`, empty when the board declares none. */\nexport function withBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { boardClosure?: FactoryRuleBoardClosure } {\n const boardClosure = resolveBoardClosure(boards, item);\n return boardClosure ? { boardClosure } : {};\n}\n\n/** `{ phase }` for spreading into an integration rule context, or `{}` when the phase is unknown. */\nexport function rulePhaseField(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { readonly phase?: FactoryRulePhaseContext } {\n const phase = rulePhaseContext(boards, item);\n return phase ? { phase } : {};\n}\n\n/**\n * The change request a review session on this card may publish checks for: the card's own one,\n * or, for an issue card in its board's pull request review phase, the pull request attached to it.\n */\nexport function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined {\n const source = workItemBranchSource(item.externalSource);\n const own = isPullRequestCard({ source });\n if (!own && (item.stages.length !== 1 || cardBoardFlow(boards, item).pullRequestReview !== item.stages[0])) {\n return undefined;\n }\n const number = reviewedChangeRequest({ ...item, source })?.number;\n if (number !== undefined) return String(number);\n // A GitHub key ends in its number (`github-pr:34`); a GitLab key is encoded, so its digits mean nothing.\n return source === 'github-pr' ? /(\\d+)$/.exec(item.externalSource?.externalId ?? '')?.[1] : undefined;\n}\n\nexport { sourceExternalId } from '../work-items/source-external-id.js';\n"],"mappings":";;;;;;;;;;;;;;AA4CA,SAAgB,iBAAiB,MAAmC;CAClE,OAAO,KAAK,SAAA;AACd;AAEA,MAAM,wBAAQ,IAAI,QAAsC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,SAAgB,UAAU,OAAyD;CACjF,IAAI,CAAC,OAAO,OAAO,OAAO,OAAO,CAAC,CAAC;CACnC,MAAM,SAAS,MAAM,IAAI,KAAK;CAC9B,IAAI,QAAQ,OAAO;CACnB,MAAM,UAAU,OAAO,QAAQ,MAAM,MAAM;CAC3C,MAAM,UAAU,OAA2B,SACzC,MAA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