@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,11 +1,13 @@
1
- import { closeReason } from "../../boards/board-events.js";
1
+ import { closeReason, listChange, updateEventFacts } from "../../boards/board-events.js";
2
2
  import "../../boards/index.js";
3
3
  import { toBoardSource } from "../../boards/project-boards.js";
4
4
  import { cardLabels } from "../../boards/relocate.js";
5
- import { boardEventHandlers, boardForWorkItem, cardBoardFlow, cardOwnsBranch, eventBoardId, intakeTarget, isTerminalWorkItem, newestOwnedOpenPullRequestNumber, pullRequestSources, rulePhaseField, withBoardClosure, withBoardFlow, workItemPhaseSemantics } from "../../boards/semantics.js";
6
5
  import { recordIntakeEvent } from "../../metrics/intake.js";
6
+ import { isPullRequestCard, pullRequestSources, trustedPullRequestSource } from "../../work-items/change-requests.js";
7
+ import { boardEventHandlers, boardForWorkItem, cardBoardFlow, cardOwnsBranch, eventBoardId, intakeTarget, isTerminalWorkItem, newestOwnedOpenPullRequestNumber, rulePhaseField, withBoardClosure, withBoardFlow, workItemPhaseSemantics } from "../../boards/semantics.js";
7
8
  import { requestsChangesVerdict } from "../../review-verdict.js";
8
- import { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from "../../rules/event-rules.js";
9
+ import { commitCardUpdate, deploymentOwnsEvent, routeEventDecision, selectEventRule, withPullRequestTrust, withoutRouteEvent } from "../../rules/event-rules.js";
10
+ import { authorTrusted } from "../../rules/types.js";
9
11
  import { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from "../../rules/validation.js";
10
12
  import { FACTORY_PULL_REQUEST_RECONCILIATION_KEY, WorkItemUpdateConflictError } from "../../storage/domains/work-items/base.js";
11
13
  import { primarySource } from "../../storage/domains/work-items/work-item-schema.js";
@@ -46,6 +48,9 @@ function number(value) {
46
48
  function boolean(value) {
47
49
  return typeof value === "boolean" ? value : void 0;
48
50
  }
51
+ function stringList(value) {
52
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
53
+ }
49
54
  function actorLogins(value) {
50
55
  if (!Array.isArray(value)) return [];
51
56
  return value.flatMap((actor) => {
@@ -97,11 +102,47 @@ function activitySignalFor(context) {
97
102
  authorTrusted: context.actor.trusted
98
103
  };
99
104
  }
105
+ /**
106
+ * A label, assignee or reopen delivery filed again as its item's author opening it, so intake
107
+ * judges the author's trust, never that of whoever labelled or reopened it. Undefined when the
108
+ * delivery doesn't name the author.
109
+ */
110
+ function openedByAuthor(parsed, item) {
111
+ const author = object(item?.user);
112
+ const login = string(author?.login);
113
+ if (!author || !login) return void 0;
114
+ return {
115
+ arrival: {
116
+ ...parsed,
117
+ deliveryId: `${parsed.deliveryId}:intake`,
118
+ payload: {
119
+ ...parsed.payload,
120
+ action: "opened",
121
+ sender: author
122
+ }
123
+ },
124
+ login
125
+ };
126
+ }
127
+ /**
128
+ * Whether the delivery's pull request comes from someone with write access, or from Factory: its
129
+ * own card's stamp, the stamp recorded when it joined the card, else its author acting now.
130
+ */
131
+ function githubPullRequestTrusted(context) {
132
+ const { pullRequest, item } = context;
133
+ if (!pullRequest) return false;
134
+ if (pullRequest.factoryAuthored) return true;
135
+ if (item && isPullRequestCard(item)) return authorTrusted(item.metadata);
136
+ const attached = item ? pullRequestSources(item).find((source) => isRepositoryPullRequest(source, context.repository.id, context.repository.fullName, pullRequest.number)) : void 0;
137
+ if (item && attached) return trustedPullRequestSource(item, attached);
138
+ return context.actor.type === "github" && context.actor.trusted && pullRequest.author !== void 0 && context.actor.login === pullRequest.author;
139
+ }
100
140
  /** The status change a GitHub delivery reports. `not_planned` and `duplicate` closes are canceled work. */
101
141
  function boardEventFor(context) {
102
142
  switch (context.event) {
103
- case "issueOpened": return { type: "work_item.created" };
143
+ case "issueOpened": return { type: "work_item.opened" };
104
144
  case "issueReopened": return { type: "work_item.reopened" };
145
+ case "pullRequestReopened": return { type: "pull_request.reopened" };
105
146
  case "issueClosed": {
106
147
  const stateReason = context.issue?.stateReason;
107
148
  return {
@@ -134,6 +175,7 @@ function eventName(parsed) {
134
175
  if (parsed.event === "pull_request" && action === "synchronize") return "pullRequestUpdated";
135
176
  if (parsed.event === "pull_request" && action === "closed") return boolean(object(parsed.payload.pull_request)?.merged) ? "pullRequestMerged" : "pullRequestClosed";
136
177
  if (parsed.event === "pull_request" && action === "review_requested") return "pullRequestReviewRequested";
178
+ if (parsed.event === "pull_request" && action === "reopened") return "pullRequestReopened";
137
179
  if (parsed.event === "pull_request_review" && action === "submitted") return "pullRequestReviewSubmitted";
138
180
  if (parsed.event === "pull_request_review" && action === "edited") {
139
181
  const review = object(parsed.payload.review);
@@ -256,7 +298,8 @@ async function githubActor(github, input) {
256
298
  type: "github",
257
299
  login: input.login,
258
300
  trusted,
259
- factoryAuthored: input.factoryAuthored
301
+ factoryAuthored: input.factoryAuthored,
302
+ human: input.human
260
303
  };
261
304
  }
262
305
  function pullRequestProvenance(data, factoryProjectId) {
@@ -269,6 +312,12 @@ function pullRequestProvenance(data, factoryProjectId) {
269
312
  }
270
313
  /** Identity under which label and assignee syncs are recorded. */
271
314
  const CARD_SYNC_USER_ID = "factory-rule-dispatcher";
315
+ const PULL_REQUEST_UPDATE_ACTIONS = /* @__PURE__ */ new Set([
316
+ "labeled",
317
+ "unlabeled",
318
+ "assigned",
319
+ "unassigned"
320
+ ]);
272
321
  /**
273
322
  * Whether a login is Factory itself. Prefers the resolved identity, which is
274
323
  * observed from Factory's own writes, and falls back to the configured slug.
@@ -308,42 +357,78 @@ var GithubRules = class {
308
357
  return slug ? `${slug.toLowerCase()}[bot]` : void 0;
309
358
  }
310
359
  /**
311
- * `labeled` / `unlabeled` are not rule events: the card's label metadata is refreshed and the card
312
- * stays where it is. Intake routes placed it when it arrived; a label change doesn't move it.
360
+ * `labeled` / `unlabeled` refresh the card's label metadata, then hand what changed to the card's
361
+ * routes as a `work_item.updated` event. Only routes naming the event move the card.
313
362
  */
314
363
  async #syncIssueLabels(parsed, repositoryId, repositoryName, project) {
315
364
  const issue = object(parsed.payload.issue);
316
365
  const issueNumber = issue?.pull_request === void 0 ? number(issue?.number) : void 0;
317
366
  if (!issueNumber) return { status: "ignored" };
318
367
  const found = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, void 0, void 0, null);
319
- if (!found || found.externalSource?.type !== "issue") return { status: "ignored" };
368
+ if (!found) return this.#intakeIfNotRouted(parsed, repositoryId, repositoryName, project, issueNumber);
369
+ if (found.externalSource?.type !== "issue") return { status: "ignored" };
320
370
  const labels = labelNames(issue?.labels);
321
- if (sameLabels(cardLabels(found), labels)) return { status: "ignored" };
322
- let updated;
371
+ const before = cardLabels(found);
372
+ const updatedAt = string(issue?.updated_at);
373
+ const payloadTime = timestamp(updatedAt);
374
+ const storedTime = timestamp(found.workItem.metadata?.githubLabelsUpdatedAt);
375
+ if (payloadTime !== void 0 && storedTime !== void 0 && payloadTime < storedTime) return { status: "ignored" };
376
+ const advancesTime = payloadTime !== void 0 && (storedTime === void 0 || payloadTime > storedTime);
377
+ if (sameLabels(before, labels) && !advancesTime) return { status: "ignored" };
378
+ if (await this.#commitUpdate(parsed, repositoryName, project, found, updateEventFacts("work_item.updated", { labels: listChange(before, labels) })) === "ignored") return { status: "ignored" };
323
379
  try {
324
- updated = await this.options.storage.syncCard({
380
+ await this.options.storage.syncCard({
325
381
  orgId: found.orgId,
326
382
  id: found.id,
327
383
  userId: CARD_SYNC_USER_ID,
328
- patch: { metadata: { labels } },
384
+ patch: { metadata: {
385
+ labels,
386
+ ...payloadTime !== void 0 ? { githubLabelsUpdatedAt: updatedAt } : {}
387
+ } },
329
388
  expectedSourceRevision: primarySource(found)?.revision
330
389
  });
331
390
  } catch (error) {
332
391
  if (!(error instanceof WorkItemUpdateConflictError)) throw error;
333
- return { status: "ignored" };
334
392
  }
335
- return { status: updated ? "committed" : "ignored" };
393
+ return { status: "committed" };
336
394
  }
337
395
  /**
338
- * `assigned` / `unassigned` are not rule events either: an existing issue card only mirrors the
339
- * issue's full assignee list. No card is created, moved, or handed to a run.
396
+ * Hands a label or assignee change to the card's routes. A change Factory made itself is the
397
+ * card's own session's, held until its run ends.
398
+ */
399
+ async #commitUpdate(parsed, repositoryName, project, item, event) {
400
+ const installationId = number(object(parsed.payload.installation)?.id);
401
+ const login = string(object(parsed.payload.sender)?.login);
402
+ if (!installationId || !login || !event) return "unchanged";
403
+ const fromCardSession = this.#isFactoryLogin(login);
404
+ const actor = await githubActor(this.options.github, {
405
+ installationId,
406
+ repository: repositoryName,
407
+ login,
408
+ factoryAuthored: fromCardSession,
409
+ human: string(object(parsed.payload.sender)?.type) === "User"
410
+ });
411
+ return await commitCardUpdate(this.options.storage, {
412
+ orgId: project.orgId,
413
+ factoryProjectId: project.factoryProjectId,
414
+ item,
415
+ ingress: { identity: `${installationId}:${parsed.deliveryId}` },
416
+ actor: { ...actor },
417
+ event,
418
+ fromCardSession
419
+ });
420
+ }
421
+ /**
422
+ * `assigned` / `unassigned` mirror the issue's full assignee list onto an existing issue card,
423
+ * then hand what changed to the card's routes as a `work_item.updated` event. No card is created.
340
424
  */
341
425
  async #syncIssueAssignees(parsed, repositoryId, repositoryName, project) {
342
426
  const issue = object(parsed.payload.issue);
343
427
  const issueNumber = issue?.pull_request === void 0 ? number(issue?.number) : void 0;
344
428
  if (!issueNumber) return { status: "ignored" };
345
429
  const item = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, void 0, void 0, null);
346
- if (!item || item.externalSource?.type !== "issue") return { status: "ignored" };
430
+ if (!item) return this.#intakeIfNotRouted(parsed, repositoryId, repositoryName, project, issueNumber);
431
+ if (item.externalSource?.type !== "issue") return { status: "ignored" };
347
432
  const assignees = actorLogins(issue?.assignees);
348
433
  const updatedAt = string(issue?.updated_at);
349
434
  const payloadTime = timestamp(updatedAt);
@@ -351,8 +436,9 @@ var GithubRules = class {
351
436
  if (payloadTime !== void 0 && storedTime !== void 0 && payloadTime < storedTime) return { status: "ignored" };
352
437
  const advancesTime = payloadTime !== void 0 && (storedTime === void 0 || payloadTime > storedTime);
353
438
  if (sameStrings(item.workItem.metadata?.assignees, assignees) && !advancesTime) return { status: "ignored" };
439
+ if (await this.#commitUpdate(parsed, repositoryName, project, item, updateEventFacts("work_item.updated", { assignees: listChange(stringList(item.workItem.metadata?.assignees), assignees) })) === "ignored") return { status: "ignored" };
354
440
  try {
355
- return { status: await this.options.storage.syncCard({
441
+ await this.options.storage.syncCard({
356
442
  orgId: item.orgId,
357
443
  id: item.id,
358
444
  userId: CARD_SYNC_USER_ID,
@@ -361,16 +447,140 @@ var GithubRules = class {
361
447
  ...payloadTime !== void 0 ? { githubAssigneesUpdatedAt: updatedAt } : {}
362
448
  } },
363
449
  expectedSourceRevision: primarySource(item)?.revision
364
- }) ? "committed" : "ignored" };
450
+ });
365
451
  } catch (error) {
366
452
  if (!(error instanceof WorkItemUpdateConflictError)) throw error;
367
- return { status: "ignored" };
368
453
  }
454
+ return { status: "committed" };
369
455
  }
370
- /** `issues` actions that are not rule events but still update an existing card. */
371
- #issueActionHandler(parsed) {
456
+ /** A reopened pull request reads open again on every card that holds it; clearing the sweep's settled stamp lets a later close replay. */
457
+ async #syncReopenedPullRequest(parsed, repositoryId, repositoryName, project) {
458
+ const pullRequest = object(parsed.payload.pull_request);
459
+ const pullRequestNumber = number(pullRequest?.number);
460
+ if (!pullRequestNumber) return { status: "ignored" };
461
+ const card = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, void 0, pullRequestNumber, void 0, null);
462
+ if (!card) return { status: "ignored" };
463
+ const open = {
464
+ state: "open",
465
+ merged: false,
466
+ draft: boolean(pullRequest?.draft) ?? false
467
+ };
468
+ const holders = [card, ...(await this.options.storage.listShared({
469
+ orgId: project.orgId,
470
+ factoryProjectId: project.factoryProjectId
471
+ })).filter((item) => item.id !== card.id && attachedPullRequestSource(item, repositoryId, repositoryName, pullRequestNumber))];
472
+ return { status: (await Promise.all(holders.map((holder) => this.#reopenPullRequestOn(holder, repositoryId, repositoryName, pullRequestNumber, open)))).some(Boolean) ? "committed" : "ignored" };
473
+ }
474
+ async #reopenPullRequestOn(card, repositoryId, repositoryName, pullRequestNumber, open) {
475
+ const attached = attachedPullRequestSource(card, repositoryId, repositoryName, pullRequestNumber);
476
+ if (attached) {
477
+ if (attached.state !== "closed") return false;
478
+ await this.options.storage.syncWorkItemSource({
479
+ orgId: card.orgId,
480
+ factoryProjectId: card.factoryProjectId,
481
+ provider: attached.provider,
482
+ externalId: attached.externalId,
483
+ patch: {
484
+ state: "open",
485
+ metadata: open
486
+ }
487
+ });
488
+ return true;
489
+ }
490
+ if (card.externalSource?.type !== "pull-request") return false;
491
+ const metadata = {
492
+ ...card.workItem.metadata,
493
+ ...card.metadata
494
+ };
495
+ if (metadata.state !== "closed") return false;
496
+ const updated = await this.options.storage.syncCard({
497
+ orgId: card.orgId,
498
+ id: card.id,
499
+ userId: CARD_SYNC_USER_ID,
500
+ patch: { metadata: {
501
+ ...open,
502
+ ...metadata["factoryPullRequestReconciliation"] === void 0 ? {} : { [FACTORY_PULL_REQUEST_RECONCILIATION_KEY]: null }
503
+ } }
504
+ });
505
+ return Boolean(updated);
506
+ }
507
+ /**
508
+ * A label or assignee added to or removed from a pull request, handed to the routes of the card it
509
+ * belongs to as `pull_request.updated`, on the pull request's own card or the issue card it is
510
+ * attached to. GitHub names the one label or assignee that changed.
511
+ */
512
+ async #pullRequestUpdate(parsed, repositoryId, repositoryName, project) {
513
+ const pullRequestNumber = number(object(parsed.payload.pull_request)?.number);
514
+ if (!pullRequestNumber) return { status: "ignored" };
515
+ const action = string(parsed.payload.action);
516
+ const name = action === "labeled" || action === "unlabeled" ? string(object(parsed.payload.label)?.name) : string(object(parsed.payload.assignee)?.login);
517
+ if (!name) return { status: "ignored" };
518
+ const item = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, void 0, pullRequestNumber, void 0, null);
519
+ if (!item) return this.#intakeIfNotRouted(parsed, repositoryId, repositoryName, project, pullRequestNumber, "pull-request");
520
+ const ownCard = item.externalSource?.type === "pull-request";
521
+ const attached = ownCard ? void 0 : attachedPullRequestSource(item, repositoryId, repositoryName, pullRequestNumber);
522
+ if (!ownCard && !attached) return { status: "ignored" };
523
+ const labelChange = action === "labeled" || action === "unlabeled";
524
+ const delta = action === "labeled" || action === "assigned" ? {
525
+ added: [name],
526
+ removed: []
527
+ } : {
528
+ added: [],
529
+ removed: [name]
530
+ };
531
+ if (attached) {
532
+ const event = updateEventFacts("pull_request.updated", labelChange ? { labels: delta } : { assignees: delta });
533
+ const queued = await this.#commitUpdate(parsed, repositoryName, project, item, event && {
534
+ ...event,
535
+ pullRequest: attached.externalId,
536
+ pullRequestTrusted: trustedPullRequestSource(item, attached)
537
+ });
538
+ return { status: queued === "committed" || queued === "replayed" ? "committed" : "ignored" };
539
+ }
540
+ const pullRequest = object(parsed.payload.pull_request);
541
+ const before = {
542
+ labels: cardLabels(item),
543
+ assignees: stringList(item.workItem.metadata?.assignees)
544
+ };
545
+ const applied = (list) => delta.added.length ? [...list, ...delta.added] : list.filter((entry) => entry.toLowerCase() !== name.toLowerCase());
546
+ const after = {
547
+ labels: Array.isArray(pullRequest?.labels) ? labelNames(pullRequest.labels) : labelChange ? applied(before.labels) : before.labels,
548
+ assignees: Array.isArray(pullRequest?.assignees) ? actorLogins(pullRequest.assignees) : labelChange ? before.assignees : applied(before.assignees)
549
+ };
550
+ const event = updateEventFacts("pull_request.updated", {
551
+ labels: listChange(before.labels, after.labels),
552
+ assignees: listChange(before.assignees, after.assignees)
553
+ });
554
+ const queued = await this.#commitUpdate(parsed, repositoryName, project, item, event && {
555
+ ...event,
556
+ pullRequestTrusted: authorTrusted(item.metadata)
557
+ });
558
+ if (queued === "ignored") return { status: "ignored" };
559
+ try {
560
+ await this.options.storage.syncCard({
561
+ orgId: item.orgId,
562
+ id: item.id,
563
+ userId: CARD_SYNC_USER_ID,
564
+ patch: { metadata: {
565
+ labels: after.labels,
566
+ assignees: after.assignees
567
+ } },
568
+ expectedSourceRevision: primarySource(item)?.revision
569
+ });
570
+ } catch (error) {
571
+ if (!(error instanceof WorkItemUpdateConflictError)) throw error;
572
+ }
573
+ return { status: queued === "unchanged" ? "ignored" : "committed" };
574
+ }
575
+ /** `issues` and `pull_request` actions that are not rule events but still update an existing card. */
576
+ #cardSyncHandler(parsed) {
577
+ const action = string(parsed.payload.action);
578
+ if (parsed.event === "pull_request") {
579
+ if (action === "reopened") return (...args) => this.#syncReopenedPullRequest(...args);
580
+ return PULL_REQUEST_UPDATE_ACTIONS.has(action ?? "") ? (...args) => this.#pullRequestUpdate(...args) : void 0;
581
+ }
372
582
  if (parsed.event !== "issues") return void 0;
373
- switch (string(parsed.payload.action)) {
583
+ switch (action) {
374
584
  case "labeled":
375
585
  case "unlabeled": return (...args) => this.#syncIssueLabels(...args);
376
586
  case "assigned":
@@ -378,6 +588,24 @@ var GithubRules = class {
378
588
  default: return;
379
589
  }
380
590
  }
591
+ /**
592
+ * An issue with no card changed labels or assignees. If intake turned it away (Not routed), it
593
+ * runs intake again the way a new issue does, so a rule naming the label can now take it.
594
+ */
595
+ async #intakeIfNotRouted(parsed, repositoryId, repositoryName, project, itemNumber, kind = "issue") {
596
+ const installationId = number(object(parsed.payload.installation)?.id);
597
+ const login = string(object(parsed.payload.sender)?.login);
598
+ const scope = {
599
+ orgId: project.orgId,
600
+ factoryProjectId: project.factoryProjectId
601
+ };
602
+ const item = object(kind === "issue" ? parsed.payload.issue : parsed.payload.pull_request);
603
+ if (!installationId || !login || string(item?.state) !== "open" || !await this.options.notRouted?.isNotRouted(scope, legacySourceKey(repositoryId, kind, itemNumber))) return { status: "ignored" };
604
+ const opened = openedByAuthor(parsed, item);
605
+ if (!opened) return { status: "ignored" };
606
+ const event = kind === "issue" ? "issueOpened" : "pullRequestOpened";
607
+ return this.#ingestProject(opened.arrival, event, installationId, repositoryId, repositoryName, opened.login, project);
608
+ }
381
609
  async ingest(parsed) {
382
610
  try {
383
611
  const result = await this.#ingest(parsed);
@@ -400,8 +628,12 @@ var GithubRules = class {
400
628
  return { status: "ignored" };
401
629
  }
402
630
  if (!installationId || !repositoryId || !repositoryName || !login) return { status: "ignored" };
403
- const issueAction = this.#issueActionHandler(parsed);
404
- const handle = event ? (project) => this.#ingestProject(parsed, event, installationId, repositoryId, repositoryName, login, project) : issueAction ? (project) => issueAction(parsed, repositoryId, repositoryName, project) : void 0;
631
+ const cardSync = this.#cardSyncHandler(parsed);
632
+ const handle = event ? async (project) => {
633
+ const synced = cardSync ? await cardSync(parsed, repositoryId, repositoryName, project) : void 0;
634
+ const result = await this.#ingestProject(parsed, event, installationId, repositoryId, repositoryName, login, project);
635
+ return result.status === "ignored" && synced?.status === "committed" ? synced : result;
636
+ } : cardSync ? (project) => cardSync(parsed, repositoryId, repositoryName, project) : void 0;
405
637
  if (!handle) return { status: "ignored" };
406
638
  const projects = await this.options.sourceControl.projectRepositories.listByExternalRepository({
407
639
  installationExternalId: String(installationId),
@@ -466,12 +698,19 @@ var GithubRules = class {
466
698
  const pullRequestFactoryAuthored = provenance !== null || this.#isFactoryLogin(pullRequestAuthor);
467
699
  const resolvedItem = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, pullRequestNumber, sameRepositoryHeadBranch(pullRequest, repositoryId), reReviewEvent ? null : provenance, senderIsResponder && !reviewEntryRequested);
468
700
  const matchedItem = reviewEntryRequested && resolvedItem?.externalSource?.type !== "pull-request" && !(resolvedItem && pullRequestNumber && attachedPullRequestSource(resolvedItem, repositoryId, repositoryName, pullRequestNumber)) ? void 0 : resolvedItem;
701
+ const reopenedItem = event === "issueReopened" ? issue : event === "pullRequestReopened" ? pullRequest : void 0;
702
+ if (reopenedItem && !resolvedItem && string(reopenedItem.state) === "open") {
703
+ const opened = openedByAuthor(parsed, reopenedItem);
704
+ if (!opened) return { status: "ignored" };
705
+ return this.#ingestProject(opened.arrival, event === "issueReopened" ? "issueOpened" : "pullRequestOpened", installationId, repositoryId, repositoryName, opened.login, project);
706
+ }
469
707
  const intake = intakeTarget(this.#boards(project));
470
708
  const actor = await githubActor(this.options.github, {
471
709
  installationId,
472
710
  repository: repositoryName,
473
711
  login,
474
- factoryAuthored: !senderIsResponder && provenance !== null || this.#isFactoryLogin(login)
712
+ factoryAuthored: !senderIsResponder && provenance !== null || this.#isFactoryLogin(login),
713
+ human: string(object(parsed.payload.sender)?.type) === "User"
475
714
  });
476
715
  if (actor.type === "github" && actor.factoryAuthored && (event === "issueCommentCreated" || event === "issueCommentEdited") && string(issueComment?.body)?.includes(FACTORY_TRIAGE_COMMENT_MARKER)) return { status: "ignored" };
477
716
  const home = event === "pullRequestOpened" && pullRequestNumber ? await this.#pullRequestHome({
@@ -623,15 +862,15 @@ var GithubRules = class {
623
862
  }) ?? activitySignalFor(context);
624
863
  if (routed) decisions = [{ ...routed }];
625
864
  }
865
+ if (context.pullRequest) {
866
+ const trusted = githubPullRequestTrusted(context);
867
+ decisions = decisions.map((entry) => withPullRequestTrust(entry, trusted));
868
+ }
626
869
  const committed = await this.options.storage.commitRuleEvaluation({
627
870
  orgId: project.orgId,
628
871
  factoryProjectId: project.factoryProjectId,
629
872
  workItemId: item?.id ?? null,
630
- ingress: {
631
- identity: ingressIdentity,
632
- triggerType: `github.${event}`
633
- },
634
- configVersion: this.options.configVersion,
873
+ ingress: { identity: ingressIdentity },
635
874
  expectedRevision: item?.revision ?? null,
636
875
  actor: { ...actor },
637
876
  outcome,
@@ -798,23 +1037,20 @@ var GithubRules = class {
798
1037
  * Linear, incident.io) carries no repository of its own to match against, so it is taken as it is.
799
1038
  * In order: the card that authored it (on a board that reviews pull requests), by provenance or session branch,
800
1039
  * when the pull request is Factory-authored or its author is trusted; it is filed there. Then,
801
- * for a trusted author only, the card of the first issue its description says it closes; an
802
- * intake route decides whether it joins that one. An untrusted author's pull request never
803
- * lands on another card, whatever it says.
1040
+ * whoever opened it, the card of the first issue its description says it closes; it links to that
1041
+ * one. Linking runs nothing: an outsider's pull request is recorded as untrusted there.
804
1042
  */
805
1043
  async #pullRequestHome(input) {
806
- if (!input.factoryAuthored && !input.authorTrusted) return void 0;
807
1044
  const items = await this.options.storage.listShared({
808
1045
  orgId: input.orgId,
809
1046
  factoryProjectId: input.factoryProjectId
810
1047
  });
811
1048
  if (items.some((item) => attachedPullRequestSource(item, input.repositoryId, input.repositoryName, input.pullRequestNumber) || item.externalSource?.type === "pull-request" && (item.externalSource.externalId === canonicalSourceKey("pull-request", input.pullRequestNumber) || item.externalSource.externalId === legacySourceKey(input.repositoryId, "pull-request", input.pullRequestNumber)) && cardBelongsToRepository(item, input.repositoryId, input.repositoryName))) return void 0;
812
1049
  const eligible = (card) => card.externalSource != null && card.externalSource.type !== "pull-request" && card.externalSource.integrationId !== "gitlab" && !isTerminalWorkItem(this.#boards(input), card) && (card.externalSource.integrationId !== "github" || cardBelongsToRepository(card, input.repositoryId, input.repositoryName));
813
- if (input.matchedItem && eligible(input.matchedItem) && cardBoardFlow(this.#boards(input), input.matchedItem).pullRequestReview !== void 0) return {
1050
+ if ((input.factoryAuthored || input.authorTrusted) && input.matchedItem && eligible(input.matchedItem) && cardBoardFlow(this.#boards(input), input.matchedItem).pullRequestReview !== void 0) return {
814
1051
  card: input.matchedItem,
815
1052
  reason: "authored"
816
1053
  };
817
- if (!input.authorTrusted) return void 0;
818
1054
  for (const issueNumber of closingIssueNumbers(input.body, {
819
1055
  provider: "github",
820
1056
  repository: input.repositoryName
@@ -1479,6 +1715,7 @@ function githubRulesOptions(github, context) {
1479
1715
  storage: context.runtime.workItems,
1480
1716
  configVersion: context.runtime.configVersion,
1481
1717
  boards: context.runtime.boards,
1718
+ ...context.runtime.notRouted ? { notRouted: context.runtime.notRouted } : {},
1482
1719
  ...context.hooks?.onRepositoryPush ? { onRepositoryPush: context.hooks.onRepositoryPush } : {}
1483
1720
  };
1484
1721
  }
@@ -1493,6 +1730,6 @@ function attachGithubReconciler(github, context, fetchPullRequest) {
1493
1730
  if (!options) return void 0;
1494
1731
  return createGithubPullRequestReconciler(options, fetchPullRequest);
1495
1732
  }
1496
- export { GithubRules, RECONCILE_ERROR_SAMPLE_LIMIT, activitySignalFor, attachGithubPullRequestDiscovery, attachGithubReconciler, attachGithubRules, attachedPullRequestSource, boardEventFor, cardBelongsToRepository, createGithubPullRequestDiscovery, createGithubPullRequestReconciler, githubItemSources, githubRulesOptions, isFactoryGithubLogin, listedPullRequestState, openPullRequestLister, polledPullRequestEvent, reconcilableIssueNumber, reconciledClosedEvent, reconciledIssueClosedEvent, reconciledIssueOpenedEvent, reconciledIssueRelabeledEvent, reconciledPullRequestOpenedEvent, sameStrings, sweepTrustLookup, trustedCollaborator };
1733
+ export { GithubRules, RECONCILE_ERROR_SAMPLE_LIMIT, activitySignalFor, attachGithubPullRequestDiscovery, attachGithubReconciler, attachGithubRules, attachedPullRequestSource, boardEventFor, cardBelongsToRepository, createGithubPullRequestDiscovery, createGithubPullRequestReconciler, githubItemSources, githubPullRequestTrusted, githubRulesOptions, isFactoryGithubLogin, listedPullRequestState, openPullRequestLister, polledPullRequestEvent, reconcilableIssueNumber, reconciledClosedEvent, reconciledIssueClosedEvent, reconciledIssueOpenedEvent, reconciledIssueRelabeledEvent, reconciledPullRequestOpenedEvent, sameStrings, sweepTrustLookup, trustedCollaborator };
1497
1734
 
1498
1735
  //# sourceMappingURL=rules.js.map