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

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 (183) hide show
  1. package/README.md +55 -31
  2. package/dist/boards/semantics.d.ts.map +1 -1
  3. package/dist/boards/semantics.js +7 -1
  4. package/dist/boards/semantics.js.map +1 -1
  5. package/dist/factory.d.ts +10 -0
  6. package/dist/factory.d.ts.map +1 -1
  7. package/dist/factory.js +98 -41
  8. package/dist/factory.js.map +1 -1
  9. package/dist/integrations/github/issue-intake.d.ts +15 -0
  10. package/dist/integrations/github/issue-intake.d.ts.map +1 -0
  11. package/dist/integrations/github/issue-intake.js +50 -0
  12. package/dist/integrations/github/issue-intake.js.map +1 -0
  13. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
  14. package/dist/integrations/github/issue-reconciler.js +10 -1
  15. package/dist/integrations/github/issue-reconciler.js.map +1 -1
  16. package/dist/integrations/github/rules.d.ts +2 -0
  17. package/dist/integrations/github/rules.d.ts.map +1 -1
  18. package/dist/integrations/github/rules.js +3 -0
  19. package/dist/integrations/github/rules.js.map +1 -1
  20. package/dist/integrations/platform/connect/routes.d.ts +43 -1
  21. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  22. package/dist/integrations/platform/connect/routes.js +82 -7
  23. package/dist/integrations/platform/connect/routes.js.map +1 -1
  24. package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
  25. package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
  26. package/dist/integrations/platform/connect/session-tools.js +28 -10
  27. package/dist/integrations/platform/connect/session-tools.js.map +1 -1
  28. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
  29. package/dist/integrations/platform/vanta/integration.js +3 -3
  30. package/dist/integrations/platform/vanta/integration.js.map +1 -1
  31. package/dist/integrations/vanta/sync.d.ts +9 -0
  32. package/dist/integrations/vanta/sync.d.ts.map +1 -1
  33. package/dist/integrations/vanta/sync.js +10 -1
  34. package/dist/integrations/vanta/sync.js.map +1 -1
  35. package/dist/routes/board-snapshot.d.ts +5 -5
  36. package/dist/routes/board-snapshot.d.ts.map +1 -1
  37. package/dist/routes/board-snapshot.js +10 -14
  38. package/dist/routes/board-snapshot.js.map +1 -1
  39. package/dist/routes/config.d.ts +11 -2
  40. package/dist/routes/config.d.ts.map +1 -1
  41. package/dist/routes/config.js +242 -75
  42. package/dist/routes/config.js.map +1 -1
  43. package/dist/routes/contracts.d.ts +43 -14
  44. package/dist/routes/contracts.d.ts.map +1 -1
  45. package/dist/routes/contracts.js +27 -17
  46. package/dist/routes/contracts.js.map +1 -1
  47. package/dist/routes/custom-endpoint-url.d.ts +8 -0
  48. package/dist/routes/custom-endpoint-url.d.ts.map +1 -0
  49. package/dist/routes/custom-endpoint-url.js +45 -0
  50. package/dist/routes/custom-endpoint-url.js.map +1 -0
  51. package/dist/routes/custom-provider-source.d.ts +24 -8
  52. package/dist/routes/custom-provider-source.d.ts.map +1 -1
  53. package/dist/routes/custom-provider-source.js +93 -43
  54. package/dist/routes/custom-provider-source.js.map +1 -1
  55. package/dist/routes/intake.d.ts +6 -0
  56. package/dist/routes/intake.d.ts.map +1 -1
  57. package/dist/routes/intake.js +20 -0
  58. package/dist/routes/intake.js.map +1 -1
  59. package/dist/routes/project-sessions.d.ts +15 -3
  60. package/dist/routes/project-sessions.d.ts.map +1 -1
  61. package/dist/routes/project-sessions.js +56 -14
  62. package/dist/routes/project-sessions.js.map +1 -1
  63. package/dist/routes/projects.d.ts +6 -1
  64. package/dist/routes/projects.d.ts.map +1 -1
  65. package/dist/routes/projects.js +19 -3
  66. package/dist/routes/projects.js.map +1 -1
  67. package/dist/routes/provider-credentials.d.ts +10 -1
  68. package/dist/routes/provider-credentials.d.ts.map +1 -1
  69. package/dist/routes/provider-credentials.js +13 -16
  70. package/dist/routes/provider-credentials.js.map +1 -1
  71. package/dist/routes/session-rows.d.ts +1 -1
  72. package/dist/routes/session-rows.d.ts.map +1 -1
  73. package/dist/routes/session-rows.js +38 -42
  74. package/dist/routes/session-rows.js.map +1 -1
  75. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  76. package/dist/routes/source-control-sessions.js +4 -4
  77. package/dist/routes/source-control-sessions.js.map +1 -1
  78. package/dist/routes/surface.d.ts +3 -0
  79. package/dist/routes/surface.d.ts.map +1 -1
  80. package/dist/routes/surface.js +20 -7
  81. package/dist/routes/surface.js.map +1 -1
  82. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  83. package/dist/routes/tenant-credentials.js +4 -4
  84. package/dist/routes/tenant-credentials.js.map +1 -1
  85. package/dist/routes/work-items.d.ts +9 -3
  86. package/dist/routes/work-items.d.ts.map +1 -1
  87. package/dist/routes/work-items.js +39 -16
  88. package/dist/routes/work-items.js.map +1 -1
  89. package/dist/rules/binding-context.d.ts +5 -0
  90. package/dist/rules/binding-context.d.ts.map +1 -1
  91. package/dist/rules/binding-context.js +51 -5
  92. package/dist/rules/binding-context.js.map +1 -1
  93. package/dist/rules/dispatcher.d.ts.map +1 -1
  94. package/dist/rules/dispatcher.js +2 -1
  95. package/dist/rules/dispatcher.js.map +1 -1
  96. package/dist/rules/start-coordinator.d.ts.map +1 -1
  97. package/dist/rules/start-coordinator.js +2 -7
  98. package/dist/rules/start-coordinator.js.map +1 -1
  99. package/dist/sandbox/session-retirement.d.ts +6 -0
  100. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  101. package/dist/sandbox/session-retirement.js +17 -0
  102. package/dist/sandbox/session-retirement.js.map +1 -1
  103. package/dist/session/factory-session.d.ts.map +1 -1
  104. package/dist/session/factory-session.js +2 -1
  105. package/dist/session/factory-session.js.map +1 -1
  106. package/dist/session/live-sessions.d.ts +6 -1
  107. package/dist/session/live-sessions.d.ts.map +1 -1
  108. package/dist/session/live-sessions.js +4 -0
  109. package/dist/session/live-sessions.js.map +1 -1
  110. package/dist/session/run-audit.d.ts +1 -1
  111. package/dist/session/run-audit.d.ts.map +1 -1
  112. package/dist/session/run-audit.js.map +1 -1
  113. package/dist/session/session-row-status.d.ts +3 -3
  114. package/dist/session/session-row-status.js +4 -4
  115. package/dist/session/session-row-status.js.map +1 -1
  116. package/dist/session/session-row-view.d.ts +3 -4
  117. package/dist/session/session-row-view.d.ts.map +1 -1
  118. package/dist/session/session-row-view.js +14 -21
  119. package/dist/session/session-row-view.js.map +1 -1
  120. package/dist/session/session-rows.d.ts +22 -8
  121. package/dist/session/session-rows.d.ts.map +1 -1
  122. package/dist/session/session-rows.js +158 -83
  123. package/dist/session/session-rows.js.map +1 -1
  124. package/dist/session/session-unloader.d.ts +101 -0
  125. package/dist/session/session-unloader.d.ts.map +1 -0
  126. package/dist/session/session-unloader.js +278 -0
  127. package/dist/session/session-unloader.js.map +1 -0
  128. package/dist/session/work-item-repository.d.ts +5 -1
  129. package/dist/session/work-item-repository.d.ts.map +1 -1
  130. package/dist/session/work-item-repository.js +39 -15
  131. package/dist/session/work-item-repository.js.map +1 -1
  132. package/dist/session-list-changes.d.ts +9 -0
  133. package/dist/session-list-changes.d.ts.map +1 -0
  134. package/dist/session-list-changes.js +54 -0
  135. package/dist/session-list-changes.js.map +1 -0
  136. package/dist/storage/announced-lists.d.ts +14 -0
  137. package/dist/storage/announced-lists.d.ts.map +1 -0
  138. package/dist/storage/announced-lists.js +78 -0
  139. package/dist/storage/announced-lists.js.map +1 -0
  140. package/dist/storage/domains/boards/base.d.ts +1 -1
  141. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  142. package/dist/storage/domains/boards/base.js +27 -9
  143. package/dist/storage/domains/boards/base.js.map +1 -1
  144. package/dist/storage/domains/custom-providers/base.d.ts +62 -19
  145. package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
  146. package/dist/storage/domains/custom-providers/base.js +131 -100
  147. package/dist/storage/domains/custom-providers/base.js.map +1 -1
  148. package/dist/storage/domains/intake/base.d.ts +25 -7
  149. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  150. package/dist/storage/domains/intake/base.js +83 -19
  151. package/dist/storage/domains/intake/base.js.map +1 -1
  152. package/dist/storage/domains/source-control/base.d.ts +8 -0
  153. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  154. package/dist/storage/domains/source-control/base.js +110 -64
  155. package/dist/storage/domains/source-control/base.js.map +1 -1
  156. package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
  157. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  158. package/dist/storage/domains/source-control/inmemory.js +8 -5
  159. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  160. package/dist/storage/domains/work-items/base.d.ts +9 -1
  161. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  162. package/dist/storage/domains/work-items/base.js +43 -11
  163. package/dist/storage/domains/work-items/base.js.map +1 -1
  164. package/dist/tools/read-tools.d.ts +9 -2
  165. package/dist/tools/read-tools.d.ts.map +1 -1
  166. package/dist/tools/read-tools.js +57 -12
  167. package/dist/tools/read-tools.js.map +1 -1
  168. package/dist/tools/session-tools.d.ts +0 -13
  169. package/dist/tools/session-tools.d.ts.map +1 -1
  170. package/dist/tools/session-tools.js +127 -336
  171. package/dist/tools/session-tools.js.map +1 -1
  172. package/dist/tools/work-item-tools.d.ts.map +1 -1
  173. package/dist/tools/work-item-tools.js +91 -23
  174. package/dist/tools/work-item-tools.js.map +1 -1
  175. package/dist/work-items/card-reference.d.ts +21 -0
  176. package/dist/work-items/card-reference.d.ts.map +1 -0
  177. package/dist/work-items/card-reference.js +58 -0
  178. package/dist/work-items/card-reference.js.map +1 -0
  179. package/package.json +8 -8
  180. package/dist/storage/probed-list.d.ts +0 -11
  181. package/dist/storage/probed-list.d.ts.map +0 -1
  182. package/dist/storage/probed-list.js +0 -52
  183. package/dist/storage/probed-list.js.map +0 -1
package/README.md CHANGED
@@ -58,15 +58,15 @@ function summarizeCard(card: Card) {
58
58
 
59
59
  Each work item has one board item. Factory's card-to-card parent link is `parentBoardItemId`. Provider sub-issue ancestry is not populated into `card.workItem.parentWorkItemId`; migrated work items leave that field null. Existing card IDs, comments, subscriptions, run bindings, and `/work-items/:id` URLs stay unchanged. The work item gets its own ID. For one release, work-item API responses also retain the legacy top-level title, external source, and merged metadata fields.
60
60
 
61
- `GET /web/factory/projects/:id/work-items` lists a project's cards. Pass `sessionId` to list only the cards holding that session and the cards related to them: a card's parent and children, and a pull request with the card whose session branch it was pushed from. Repeat `sessionId` to list several sessions' cards. Pass `scope=sessions` to list the cards holding any session and the cards related to them, without naming the sessions; it can't be combined with `sessionId`. Pass `started=false` to list the cards holding no session, most recently updated first: `limit` sets how many are sent (20 unless given, 50 at most), `q` keeps the cards whose title, key, number or source id contains every word in it, in any case, and `total` in the response counts every card that matched, sent or not. `started=false` can't be combined with `scope` or `sessionId`, and `q` is accepted only with it. Repeat `source` (up to 100 values) to list the cards filed from those sources, each named by its source id or its URL, whatever sessions the cards hold; it can't be combined with `started`, `scope` or `sessionId`. Repeat `workItemId` (up to 100 values) to list the cards with those ids and no other, whatever sessions they hold; an id no card has is left out, so asking for one card that was deleted answers 200 with an empty list. It can't be combined with `source`, `started`, `scope` or `sessionId`. A query the route can't answer gets a 400, never the whole board. Apart from `total`, the response has the same shape in every case, and `runningSessionIds` and `parkedSessionIds` cover only the listed cards.
61
+ `GET /web/factory/projects/:id/work-items` lists a project's cards. Pass `sessionId` to list only the cards holding that session and the cards related to them: a card's parent and children, and a pull request with the card whose session branch it was pushed from. Repeat `sessionId` to list several sessions' cards. Pass `scope=sessions` to list the cards holding any session and the cards related to them, without naming the sessions; it can't be combined with `sessionId`. Pass `started=false` to list the cards holding no session, most recently updated first: `limit` sets how many are sent (20 unless given, 50 at most), `q` keeps the cards whose title, key, number or source id contains every word in it, in any case, and `total` in the response counts every card that matched, sent or not. `started=false` can't be combined with `scope` or `sessionId`, and `q` is accepted only with it. Repeat `source` (up to 100 values) to list the cards filed from those sources, each named by its source id or its URL, whatever sessions the cards hold; it can't be combined with `started`, `scope` or `sessionId`. Repeat `workItemId` (up to 100 values) to list the cards with those ids and no other, whatever sessions they hold; an id no card has is left out, so asking for one card that was deleted answers 200 with an empty list. It can't be combined with `source`, `started`, `scope` or `sessionId`. A query the route can't answer gets a 400, never the whole board. Apart from `total`, the response has the same shape in every case.
62
62
 
63
63
  The whole-board listing also returns a `cursor`, and each card carries `changedAt`, when it last changed. Send the cursor back as `since` to get only what moved since that read: `workItems` then holds the cards changed, `removedIds` the cards deleted, and `check` a value naming every card on the board and when it last changed, with the next `cursor`. A reader merges these into the board it kept, then compares `boardCheck` of its merged cards (exported from `@mastra/factory/work-items/board-check`) with `check`, and reads the board whole again when they differ. A `since` the server can't answer from is ignored, not refused, so the answer is the listing as it would be without it, with no `removedIds`: a malformed cursor, a board that returned no `cursor`, or a listing narrowed by `sessionId`, `scope`, `started`, `source` or `workItemId`.
64
64
 
65
65
  Two reads answer questions about a project's cards without listing them. `GET /web/factory/projects/:id/work-items/starters` counts the cards on the default board that each new-session starter would act on: cards whose run failed, pull requests with changes requested, pull requests waiting for review (with when the oldest was opened), triaged cards waiting on a person, untriaged cards, bugs with no plan, the label with the most cards not started, and stale pull requests. Failed runs are read from the 50 newest run decisions, as on the cards. `GET /web/factory/projects/:id/work-items/activity?since=<ISO 8601 instant>` returns how many cards the project has, and when cards were created and completed from `since` on; a missing or malformed `since` is a 400. Its answer carries an `ETag`: ask again for the same `since` with `If-None-Match`, and an answer that did not change comes back as a 304 with no body.
66
66
 
67
- Two more reads serve a board without sending every card. `GET /web/factory/projects/:id/boards/:boardKey/phases` returns one entry per phase of the board in `phases`, in the board's order: `phase` is its id, `total` counts the cards in it, and `cards` names the first of them as `{ id, version }`. `version` names the card's body: it is another value whenever anything in the body is, including a change that leaves `changedAt` as it was. `limit` sets how many each phase names (50 unless given, 200 at most), `window=<phase>:<count>` (repeatable) names more cards of one phase, and `item=<card id>` asks for one card wherever it lies: the answer names it in `item` as `{ id, version, places }`, where `places` gives each phase the view lists it under and its `position` there (how many cards the phase lists before it), and `cards=true` sends its body. No phase names more cards for it, so the answer is the same size for the oldest card of a phase as for the newest. `places` is empty when the search or filters leave the card out, and `item` is absent when the board does not hold the card. `sort` is `recent` (latest entry into the phase first, the default), `recent-mine` (the cards the signed-in user last moved into the phase first), `created-newest` or `created-oldest`. `q` keeps the cards whose title, key, number or source id contains every word in it; `label`, `source`, `linearProject`, `teammate`, `author`, `assignee`, `reviewer` and `worked` (all repeatable) keep the cards matching every field given. `boardTotal` counts the board's cards whatever the search and filters, `matchingTotal` the cards matching them, a card in two phases once. `related` names the cards related to a named card that no phase names, the first `limit` of each card's, and `relatedTotal` counts them all, and `runningSessionIds` and `parkedSessionIds` cover the named cards. Pass `cards=true` to also receive the body of every named card in `workItems`, each with its `version`; without it, read the cards whose `version` differs from the copy you kept with `GET /web/factory/projects/:id/work-items?workItemId=<id>`, which sends each card with its `version` too. A card in none of the board's phases is counted in the first one. A malformed parameter is a 400 `invalid_phases_query`; a board the project doesn't have is a 404; a `window` for a phase the board doesn't have is ignored. `GET /web/factory/projects/:id/work-items/filter-options` returns what a board can be filtered by, over every card of the project: `labels`, sorted; `people`, each person a source names as author, assignee or requested reviewer, as `{ id, name, source }`; and `actorIds`, the Factory users who filed, moved or started a card. Both answers carry an `ETag`; send it back as `If-None-Match` and an unchanged answer is a 304.
67
+ Two more reads serve a board without sending every card. `GET /web/factory/projects/:id/boards/:boardKey/phases` returns one entry per phase of the board in `phases`, in the board's order: `phase` is its id, `total` counts the cards in it, and `cards` names the first of them as `{ id, version }`. `version` names the card's body: it is another value whenever anything in the body is, including a change that leaves `changedAt` as it was. `limit` sets how many each phase names (50 unless given, 200 at most), `window=<phase>:<count>` (repeatable) names more cards of one phase, and `item=<card id>` asks for one card wherever it lies: the answer names it in `item` as `{ id, version, places }`, where `places` gives each phase the view lists it under and its `position` there (how many cards the phase lists before it), and `cards=true` sends its body. No phase names more cards for it, so the answer is the same size for the oldest card of a phase as for the newest. `places` is empty when the search or filters leave the card out, and `item` is absent when the board does not hold the card. `sort` is `recent` (latest entry into the phase first, the default), `recent-mine` (the cards the signed-in user last moved into the phase first), `created-newest` or `created-oldest`. `q` keeps the cards whose title, key, number or source id contains every word in it; `label`, `source`, `linearProject`, `teammate`, `author`, `assignee`, `reviewer` and `worked` (all repeatable) keep the cards matching every field given. `boardTotal` counts the board's cards whatever the search and filters, `matchingTotal` the cards matching them, a card in two phases once. `related` names the cards related to a named card that no phase names, the first `limit` of each card's, and `relatedTotal` counts them all. Pass `cards=true` to also receive the body of every named card in `workItems`, each with its `version`; without it, read the cards whose `version` differs from the copy you kept with `GET /web/factory/projects/:id/work-items?workItemId=<id>`, which sends each card with its `version` too. A card in none of the board's phases is counted in the first one. A malformed parameter is a 400 `invalid_phases_query`; a board the project doesn't have is a 404; a `window` for a phase the board doesn't have is ignored. `GET /web/factory/projects/:id/work-items/filter-options` returns what a board can be filtered by, over every card of the project: `labels`, sorted; `people`, each person a source names as author, assignee or requested reviewer, as `{ id, name, source }`; and `actorIds`, the Factory users who filed, moved or started a card. Both answers carry an `ETag`; send it back as `If-None-Match` and an unchanged answer is a 304.
68
68
 
69
- Two reads serve the sidebar's sessions without sending every session and every card holding one. `GET /web/factory/projects/:id/session-rows` returns the rows of one view of the project's sessions, built on the server: one row per card for a card's sessions (`cardSessionIds` names them all; `children=true` lists the others under the row in `childRows` instead), and one row per session a person or Slack started. Each row carries its `session`, its `status` (`waiting`, `working`, `initializing`, `idle` or `done`), the card it works on, and the card's pull or merge request. `sort` is `activity` (the default), `updated` or `created`; `groupBy` is `none` (the default), `board`, `status` or `owner`; `owner` is `all`, `mine` or `owner:<user id>`; `status` and `updated` (`24h`, `7d` or `30d`) keep the matching rows. `groups` lists the groups holding a matching row, in the order their first row sorts, each with its `key`, its `total` and its first 5 `rows`; `window=<group key>:<count>` (repeatable, 500 at most) lists more of one group. `pin=<session id>` (repeatable) lists sessions before every other one of their group, and `open=<session id>` keeps that session's row listed in its group however deep it lies, with its place in `openIndex`. `total` counts every row, `matching` the rows the filters keep, and `boards` and `owners` name every board and person some row has, whatever the filters. `GET /web/factory/projects/:id/session-activity` returns which sessions are running, waiting on a person's answer or still coming up, and how many cards have a session working or waiting. In both answers `settling` is `true` while a session is still coming up: the answer will change with no event to say so, so ask again. Both carry an `ETag`; send it back as `If-None-Match` and an unchanged answer is a 304. A malformed `session-rows` parameter is a 400 `invalid_session_rows_query`.
69
+ Two reads serve the sidebar's sessions without sending every session and every card holding one. `GET /web/factory/projects/:id/session-rows` returns the rows of one view of the project's sessions, built on the server: one row per card for a card's sessions (`cardSessionIds` names them all; `children=true` lists the others under the row in `childRows` instead), and one row per session a person or Slack started. Each row carries its `session`, its `status` (`waiting`, `working`, `initializing`, `idle` or `done`), the card it works on, and the card's pull or merge request. `sort` is `activity` (the default), `updated` or `created`; `groupBy` is `none` (the default), `board`, `status` or `owner`; `owner` is `all`, `mine` or `owner:<user id>`; `status` and `updated` (`24h`, `7d` or `30d`) keep the matching rows. `groups` lists the groups holding a matching row, in the order their first row sorts, each with its `key`, its `total` and its first 5 `rows`; `window=<group key>:<count>` (repeatable, 500 at most) lists more of one group. `pin=<session id>` (repeatable) lists sessions before every other one of their group, and `open=<session id>` keeps that session's row listed in its group however deep it lies, with its place in `openIndex`. `total` counts every row, `matching` the rows the filters keep, and `boards` and `owners` name every board and person some row has, whatever the filters. `GET /web/factory/projects/:id/session-activity` returns which sessions are running or waiting on a person's answer, each card's status as its row in `session-rows` shows it in `cardStatuses` (only cards neither idle nor done), the cards one of whose sessions is coming up, running or parked on a person in `sessionHeldCardIds` (no other run may start on those), and how many of the cards in `cardStatuses` are working or waiting. Every write that changes either answer sends a frame on the project's feed, whichever replica made it: read again on a frame. Both carry an `ETag`; send it back as `If-None-Match` and an unchanged answer is a 304. A malformed `session-rows` parameter is a 400 `invalid_session_rows_query`.
70
70
 
71
71
  #### Migration and dry run
72
72
 
@@ -640,7 +640,7 @@ Each session context a card uses (`triage`, `work`, `review`, or a custom board'
640
640
  - **Finishing.** Entering a terminal phase stops every sandbox the card holds. A Factory process that never opened a sandbox stops it by identity through the configured sandbox provider, so a card finished on any replica stops its sandboxes.
641
641
  - **Coming back.** Stopping keeps the session, its branch and its files. A card that comes back to a context (PR review → Triage) resumes the same sandbox: E2B resumes the paused VM, Docker restarts the container, and the local sandbox reuses its directory. Platform sandboxes are not stopped remotely; they idle out under the environment's policy and the next run reattaches.
642
642
 
643
- Stopping is best-effort: a committed move never fails because a sandbox did not stop, and a card moved again before the stop runs keeps its sandbox. Deleting a session still destroys its sandbox.
643
+ Stopping is best-effort: a committed move never fails because a sandbox did not stop, and a card moved again before the stop runs keeps its sandbox. Deleting a session still destroys its sandbox. A session whose sandbox stops is also unloaded from server memory, see [Unloading idle sessions](#unloading-idle-sessions).
644
644
 
645
645
  #### The pull request loop on any board
646
646
 
@@ -744,6 +744,23 @@ The board shows how many automated runs are waiting, and opens a list of them, o
744
744
  - `running` and `claimed` — the project's automated runs a server holds a slot for, on any replica. A manual start holding a slot counts in `slots.inUse` but not here, so `running` can be lower than `inUse`.
745
745
  - `queuedCount` and `queued` — every run waiting for a slot, and up to 50 of them, waiting replies first, then automated runs, each oldest first, with their `lane` (`interactive` for a person's reply, else `automated`), `position` within that lane, card, phase and the skill they will run. `queuedByLane` splits `queuedCount` by lane. A retry still backing off is not waiting yet.
746
746
 
747
+ ### Unloading idle sessions
748
+
749
+ A loaded session holds its conversation, tool results, workspace and process output in server memory. Factory unloads a session from the process when it no longer needs it, so memory follows the sessions in use rather than every session the process has ever opened:
750
+
751
+ - **Released.** When Factory stops a session's sandbox (a card leaves the context, or finishes) the session is unloaded too.
752
+ - **Idle.** A session with no activity for 30 minutes is unloaded. Each process checks its own sessions once a minute.
753
+
754
+ A session stays loaded while a run is in flight, while it waits on an approval or an `ask_user` / `submit_plan` answer, and while a browser tab follows its stream. An idle session also stays loaded while its sandbox runs a background process the agent started, such as a dev server, because the agent can only read or stop that process through the loaded session. A released session that is busy is unloaded once its work ends.
755
+
756
+ Unloading keeps the thread, its messages, the session row and the sandbox. Unloading does not stop the sandbox; a released session's sandbox was already stopped by the release. The next message, run, wake or opened tab loads the session again on its thread and reattaches to the sandbox. Without `auth`, a deferred wake for an unloaded session waits until something else loads it, as it does after a restart. What lives only in memory is lost: session state not stored on the thread, auto-approvals granted in the session, and events from before the reload.
757
+
758
+ Change the timeout and check interval with `idleSessionUnload`. `idleMs: 0` turns off the idle check but still unloads released sessions, and `false` keeps every session loaded until it is deleted:
759
+
760
+ ```ts
761
+ const factory = new MastraFactory({ storage, idleSessionUnload: { idleMs: 60 * 60_000, sweepIntervalMs: 5 * 60_000 } });
762
+ ```
763
+
747
764
  ### The `factory-work-item` signal
748
765
 
749
766
  Every session bound to a card gets a `<factory-work-item>` state signal describing it, re-rendered only when the card, its sources or the binding change. It carries the card's key, title, URL, board and phase, next phases, labels, author and whether they're trusted, and the session's branch; its sources (issue and each pull or merge request, with state, head commit, a head branch that passes Factory's branch-name check, and the tool to fetch details); and Factory's state: whether the plan was approved, self-review rounds used, the last self-review and PR review verdicts with the commits they covered and findings, and the card's open change request. The session that reviews a pull request also gets the procedure to follow, the checkout steps and the pull request head to review. The source description is included, inside an `<untrusted-source-description>` block when an outside author wrote it. Comment threads are not included.
@@ -921,7 +938,9 @@ Intake bindings are explicit. A Linear project, Jira project, GitLab project, in
921
938
 
922
939
  - **Linear:** each project binding feeds one Factory project.
923
940
  - **Jira:** One Jira project can feed several Factory projects: each binding takes either all issues or only issues carrying its labels (Settings › Intake › Jira routing, or `labels` on `PUT /web/intake/bindings`). Each label belongs to one binding per Jira project, and only one binding per project can take all issues. Label bindings win over the all-issues binding; an issue carrying labels of two label bindings goes to the binding created first. The split happens in the JQL each Factory sends, so every issue is filed in exactly one Factory. Labels only decide placement when an issue is first filed: relabelling an issue, or editing a binding's labels, does not move existing cards. Remove one Factory's binding with `DELETE /web/intake/bindings?integrationId=jira&sourceId=…&factoryProjectId=…`. The create-Factory flow can select a Jira project and binds it to the new Factory. Both `JiraIntegration` and `PlatformJiraIntegration` run a reconciliation sweep every five minutes by default, with or without an open browser: it reads the 150 most recently updated issues of each routed Jira project (five pages, counted per project so a busy one cannot starve the others) and files a work item for each new one, refreshes the status and metadata of imported cards, and transitions the linked card of a closed issue to done or canceled. Both accept a `rules` option to replace or disable the `issueObserved` / `issueClosed` defaults. Agents on Jira-sourced runs get `jira_get_issue` and `jira_create_comment`. Set `MASTRACODE_JIRA_RECONCILE_INTERVAL_MS` to a positive millisecond interval to change its cadence.
924
- - **GitHub:** every repository linked to the project feeds it. To send one repository's issues and pull requests to another board, add an intake route with a `source.repository` condition; for labelled issues, an `item.labels` condition. A label change on an issue updates its card's labels and never moves the card.
941
+ - **GitHub:** pull requests come from every repository linked to the project. Issues come only from repositories in the organization's GitHub list in Settings › Work Intake; linking a repository adds it to that list unless the link request sends `selectIntake: false`, and adding a repository to the list brings in its open issues. To send one repository's issues and pull requests to another board, add an intake route with a `source.repository` condition; for labelled issues, an `item.labels` condition. A label change on an issue updates its card's labels and never moves the card.
942
+
943
+ Each connected service in Settings › Work Intake lists the sources it brings in, and a service with no source selected brings in nothing: there is no separate on/off switch, and a selection saved while a service was switched off reads as empty. Vanta has a single source, every active vulnerability on the connected account, which syncs only while it is selected. Dependabot alerts keep their own switch.
925
944
 
926
945
  Label routes (`GET`/`PUT /web/intake/label-routes`) and a binding's `board` were removed: use an intake route with any condition on the work item instead, such as `item.labels contains release` or `source.repository equals acme/app`. The label-route endpoints answer `410` with `label_routes_removed`, and a `board` an older client still sends on `PUT /web/intake/bindings` is ignored. Their stored rows stay, unread.
927
946
 
@@ -1321,7 +1340,7 @@ Both integrations expose incidents and incident follow-ups as separate Intake so
1321
1340
 
1322
1341
  ### Linear workspace connections
1323
1342
 
1324
- For Platform-managed Linear connections, **Settings → Work Intake** connects and repairs workspaces in place. A disconnected workspace with saved sources shows **Reconnect** on the Linear card; healthy ones need no action. A disconnected workspace without saved sources has nothing paused, so it has no Reconnect; authorize it again with **Connect**. To add another workspace, choose **Connect** next to Linear under **Add a source**. During reconnection, choose the named workspace in Linear. Factory checks that workspace's connection when authorization returns.
1343
+ For Platform-managed Linear connections, **Settings → Work Intake** connects and repairs workspaces in place. A disconnected workspace with saved sources shows **Reconnect** on the Linear card; healthy ones need no action. A disconnected workspace without saved sources has nothing paused, so it has no Reconnect; authorize it again with **Connect**. To add another workspace, choose **Add workspace** on the Linear card. During reconnection, choose the named workspace in Linear. Factory checks that workspace's connection when authorization returns.
1325
1344
 
1326
1345
  Work Intake keeps disconnected workspaces' saved sources and routing. Their issues remain paused until access is restored. A request failure shows a retry action and does not mark the workspace disconnected. Sources and polling from healthy workspaces remain available when another workspace's source request fails.
1327
1346
 
@@ -1374,25 +1393,25 @@ A repository maintainer with write or admin access can start a Factory review fr
1374
1393
 
1375
1394
  A person's own Factory session (a user session) gets tools to find, file and manage the Factory's work items through its agent. Factory scopes the tools from the stored session row, never from the thread's `factoryProjectId` tag: the session must belong to a Factory in the caller's organization, and a private session only works for its owner. With authentication disabled, the shared `local` tenant applies. Sessions doing work for someone else, either bound to a work item's run or started as a side session, only get `factory_message_origin`, so they can report back and answer messages.
1376
1395
 
1377
- | Tool | Input |
1378
- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1379
- | `factory_list_work_items` | Optional `query` (title text or `#number`), `stage`, `board`, `role`, `active`, `requestedBy: 'me'`, `subscribed`, `limit` (default 25, max 50) |
1380
- | `factory_inspect_work_item` | `workItem` (id or `#number`) |
1381
- | `factory_list_attention` | Optional `limit` (max 50) |
1382
- | `factory_list_audit_events` | Optional `actor` (`me`, a user id or `agent:<threadId>`), `includeAgentRuns`, `namespace`, `actions`, `workItem`, `since`, `until`, `cursor`, `limit` (max 50) |
1383
- | `factory_create_work_item` | `title`, `description`, optional `repository` (`owner/name`, one this Factory links) |
1384
- | `factory_update_work_item` | `workItem` plus any of `title`, `description`, `repository`, `parentWorkItem` (or `null` to detach) |
1385
- | `factory_subscribe_work_item` | `workItem` |
1386
- | `factory_unsubscribe_work_item` | `workItem` |
1387
- | `factory_transition_work_item` | `workItem`, `stage` |
1388
- | `factory_retry_decision` | `decisionId` |
1389
- | `factory_dismiss_decision` | `decisionId` |
1390
- | `factory_resolve_proposal` | `decisionId`, `action` (`approve` or `dismiss`) |
1391
- | `factory_start_session` | `prompt` (up to 8000 characters), optional `title`, optional `model`; for a work-item role, `workItem` and `role` |
1392
- | `factory_answer_approval` | `sessionId`, `toolCallId`, `decision` (approve or decline), optional `reason` |
1393
- | `factory_switch_session_model` | `sessionId`, `modelId` |
1394
- | `factory_signal_session` | `sessionId`, `message` (up to 4000 characters), optional `priority` (`low`, `medium`, `high`, `urgent`; default `medium`) |
1395
- | `factory_message_origin` | `message`, optional `inReplyTo` (the message's notification id), optional `status` (`progress`, `blocked`, `done`, `failed`) |
1396
+ | Tool | Input |
1397
+ | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1398
+ | `factory_list_work_items` | Optional `query` (title text, `#number`, or an issue or pull request reference), `stage`, `board`, `role`, `active`, `requestedBy: 'me'`, `subscribed`, `limit` |
1399
+ | `factory_inspect_work_item` | `workItem` (id, `#number`, or an issue or pull request reference) |
1400
+ | `factory_list_attention` | Optional `limit` (max 50) |
1401
+ | `factory_list_audit_events` | Optional `actor` (`me`, a user id or `agent:<threadId>`), `includeAgentRuns`, `namespace`, `actions`, `workItem`, `since`, `until`, `cursor`, `limit` (max 50) |
1402
+ | `factory_create_work_item` | `title`, `description`, optional `repository` (`owner/name`, one this Factory links) |
1403
+ | `factory_update_work_item` | `workItem` plus any of `title`, `description`, `repository`, `parentWorkItem` (or `null` to detach) |
1404
+ | `factory_subscribe_work_item` | `workItem` |
1405
+ | `factory_unsubscribe_work_item` | `workItem` |
1406
+ | `factory_transition_work_item` | `workItem`, `stage`, optional `rerun` |
1407
+ | `factory_retry_decision` | `decisionId` |
1408
+ | `factory_dismiss_decision` | `decisionId` |
1409
+ | `factory_resolve_proposal` | `decisionId`, `action` (`approve` or `dismiss`) |
1410
+ | `factory_start_session` | `prompt` (up to 8000 characters), optional `title`, optional `model` |
1411
+ | `factory_answer_approval` | `sessionId`, `toolCallId`, `decision` (approve or decline), optional `reason` |
1412
+ | `factory_switch_session_model` | `sessionId`, `modelId` |
1413
+ | `factory_signal_session` | `sessionId`, `message` (up to 4000 characters), optional `priority` (`low`, `medium`, `high`, `urgent`; default `medium`) |
1414
+ | `factory_message_origin` | `message`, optional `inReplyTo` (the message's notification id), optional `status` (`progress`, `blocked`, `done`, `failed`) |
1396
1415
 
1397
1416
  Read tools and `factory_message_origin` are available on every turn. The other tools only appear on turns a signed-in person started, so text arriving from a notification, webhook or channel can't drive them. The one exception is `factory_signal_session`: on those turns it can still message the side sessions this session started and the active sessions of work items it follows, so the session can answer the sessions it is waiting on. None of them asks for approval: they are allowed on the session when it's created, unless the person has set their own policy for the tool or for the `mcp` category.
1398
1417
 
@@ -1400,6 +1419,10 @@ Read tools and `factory_message_origin` are available on every turn. The other t
1400
1419
 
1401
1420
  `factory_create_work_item` files the card as the caller where the project's [intake routes](#intake-routes) send it, or in the Work board's first phase when no route matches (a project without Work: its first board's), stores the description that its runs start from, and subscribes the session. Name the `repository` when you know it. A run on a card that names none starts in the environment's first repository, determines from the card which repository it belongs to, and records it on the card with its first push or change request. `factory_update_work_item` sets it afterwards, like choosing a repository on the card, and also edits the title, the description and the parent item. It can't pre-approve plans: a plan waits for a person unless the board's phase auto-approves it. Both refuse a repository the Factory doesn't link, and a card synced from an issue keeps the issue's repository. Stages, the board and role sessions aren't fields it edits; stages move with `factory_transition_work_item`. A session that moves a card follows it from then on, so it hears from the run the move starts. Subscriptions are stored per work item and session in the `factory_work_item_subscriptions` collection and are removed with the item, so any number of sessions can follow one item.
1402
1421
 
1422
+ Every tool that takes `workItem` accepts the card's id, its `#number`, or the issue or pull request it tracks: its link (`https://github.com/acme/app/pull/12`, including links to a pull request's files or a comment), `owner/repo#12`, `group/project!7` for a GitLab merge request, or a tracker key such as `ENG-42`. A reference finds the issue's or pull request's own card first, then the card it is attached to, such as a pull request on its issue's card. A bare `#number` can belong to several repositories and prefers an issue's card, so with several repositories the link is the safe choice. A reference that matches more than one card is refused with the candidates' ids. `factory_list_work_items` takes the same references as its `query`.
1423
+
1424
+ `factory_transition_work_item` sends the requests the board's own buttons send, through the same rules: a move to another stage, or, with `rerun: true` and the stage the card is already in, a rerun of that stage, as **Start** does on the board. Asked for the card's own stage without `rerun`, it changes nothing and says so, including whether the stage's run is waiting for approval, so "move it to review" on a card that was already reviewed doesn't start another review. On a turn a person started, the run either one starts counts as approved by that person, so a run the board was holding for approval no longer waits, and a card that already has a run in flight or queued is refused as busy, as on the board. A rerun needs a person in the turn. Its result has the card's `url`, so a chat can link the card it moved. Approving a held run with `factory_resolve_proposal` starts it as the person. Retrying a failed one with `factory_retry_decision` keeps the run's original approver and needs no person in the turn. Either one makes the session follow the run's card in the same way, and their results carry the card's `url`. Following is what lets the run's report reach the session, which can then pass the outcome on in its chat. `factory_inspect_work_item` lists the card's stage, whether it can run again, and the stages its board lets it move to next, with the keys the tool takes. When someone asks for a card's own stage work without naming a session, such as a review of a pull request that has a card, the agent moves or reruns the card, so the review is recorded on the card and posted on the pull request. A side session is for work the person asks to run in one, and for work no stage does, such as pushing fixes to a pull request or taking it over.
1425
+
1403
1426
  #### Messaging between sessions
1404
1427
 
1405
1428
  `factory_signal_session` messages any other session in the same Factory that the caller can see: a work item's role session, or a teammate's session that isn't private. The message arrives as a `factory-session` notification on that session's own thread. Factory brings an offline session back online first, and the turn it wakes runs as that session's owner, with the owner's credentials, never as the sender.
@@ -1410,12 +1433,11 @@ How a message is delivered depends on its priority. `urgent` always delivers, ev
1410
1433
 
1411
1434
  #### Sub-sessions
1412
1435
 
1413
- `factory_start_session` starts another session for the caller and sends `prompt` as its first message. It has two modes:
1436
+ `factory_start_session` starts a side session for the caller and sends `prompt` as its first message: a standalone session with no work item, for work the person asks to run in a side session, or work no card stage does, such as an investigation or pushing fixes to an existing pull request. It uses the same repository as the session that started it. Factory stores that session on the new session's row (`origin_session_id`, `origin_thread_id`) and copies the parent's visibility. It runs on the model of the session that started it, or on `model` when one is passed. That model has to be one the session's credentials can run; an unknown or unrunnable model is refused before anything is created. When the parent has no model set, the side session keeps the Factory's default worker model.
1414
1437
 
1415
- - **Side session** (no `workItem`): a standalone session with no work item, for a one-off job. It uses the same repository as the session that started it. Factory stores that session on the new session's row (`origin_session_id`, `origin_thread_id`) and copies the parent's visibility. It runs on the model of the session that started it, or on `model` when one is passed. That model has to be one the session's credentials can run; an unknown or unrunnable model is refused before anything is created. When the parent has no model set, the side session keeps the Factory's default worker model.
1416
- - **Work-item role** (`workItem` and `role`): starts a role the item's board seats, the same way **Start** does in the Factory UI. The card does not move and no autonomy is armed. The tool refuses when the role already has a session, naming it so the agent can message it instead. An item that names no repository among several starts in the environment's first repository, and the run determines from the card which one to work in. The caller is subscribed to the item, and the run is recorded as `factory.run.started` with the caller as the person who started it.
1438
+ The tool doesn't start a card's roles. A card's work starts the way the board starts it, with `factory_transition_work_item`, so the board's rules (which stage the card is in, whether it is busy) decide it, and the card's session belongs to whoever the board's runs belong to.
1417
1439
 
1418
- A side session belongs to the caller and runs with the caller's credentials. A work-item role belongs to the caller only in a Factory on the `user` model scope. Where card work runs on the organization's keys (`factory` and `hybrid`), the role's session belongs to the Factory itself, as every phase session there does, whoever started or moved the card: the person is recorded as the one who started it, and their session follows the card so it hears when that run waits on someone and can approve or decline from there. Without an organization model key the start is refused with a message saying to add one. A work-item role keeps the Factory's default worker model. The first message runs with only the session's owner as its user, never the rest of the parent turn's context. The tool needs no approval but, like the other management tools, only appears on turns a signed-in person started.
1440
+ A side session belongs to the caller and runs with the caller's credentials. The first message runs with only the session's owner as its user, never the rest of the parent turn's context. The tool needs no approval but, like the other management tools, only appears on turns a signed-in person started.
1419
1441
 
1420
1442
  #### Reports
1421
1443
 
@@ -1452,9 +1474,9 @@ The tools take their scope as an argument rather than reading the request, so th
1452
1474
 
1453
1475
  ### Mastra Connect and your own tools in sessions
1454
1476
 
1455
- With Platform credentials and `MASTRA_PROJECT_ID`, every Factory session gets the [Mastra Connect](https://mastra.ai/docs/mastra-platform/connect) tools of each connection attached to the Platform project. Attach and remove connections in Mastra Platform, on the project's **Connect** page. The organization's other connections reach sessions only once they're attached, and a new project has none. **Settings → Tools** lists what sessions get, read from the same Platform list. Platform deploys get both variables automatically. Anywhere else, including locally, set `MASTRA_PROJECT_ID` and `MASTRA_PLATFORM_SECRET_KEY` or `MASTRA_PLATFORM_ACCESS_TOKEN`. Attach Linear, and a Slack thread, a web chat or a work item can ask about its issues.
1477
+ With Platform credentials and `MASTRA_PROJECT_ID`, every Factory session gets the [Mastra Connect](https://mastra.ai/docs/mastra-platform/connect) tools of each connection attached to the Platform project. Attach and remove connections in Mastra Platform, on the project's **Connect** page. The organization's other connections reach sessions only once they're attached, and a new project has none. **Settings → Tools** lists what sessions get, read from the same Platform list. Expand a connection to see its tools, resolved the way a session you start would resolve them: tools that ask for approval are marked, and tools Factory leaves out are listed with the reason. Platform deploys get both variables automatically. Anywhere else, including locally, set `MASTRA_PROJECT_ID` and `MASTRA_PLATFORM_SECRET_KEY` or `MASTRA_PLATFORM_ACCESS_TOKEN`. Attach Linear, and a Slack thread, a web chat or a work item can ask about its issues.
1456
1478
 
1457
- Sessions run these tools without asking while automatic approval is on, so only attach accounts whose actions sessions may take. When a person turns approval off, the tools follow the `mcp` permission category, except in Slack with `adapterOptions.toolDisplay: 'text'`, where every tool call is approved automatically. Tools with `delete` or `archive` anywhere in their name, in any case, are left out. That check goes by name only, so it can't catch every destructive action, such as a SQL tool running a `DROP`. GitHub and GitLab Connect tools are left out too: Factory's own source-control tools enforce repository scope and self-review, and Connect's would skip both. Every user and organization on the Factory shares the project's connections, and a connection attached for another app on the same project reaches Factory sessions too. `GET /web/integrations/platform/connect-tools` backs the settings page.
1479
+ Sessions run these tools without asking while automatic approval is on, so only attach accounts whose actions sessions may take. When a person turns approval off, the tools follow the `mcp` permission category, except in Slack with `adapterOptions.toolDisplay: 'text'`, where every tool call is approved automatically. Tools with `delete` or `archive` anywhere in their name, in any case, are left out. That check goes by name only, so it can't catch every destructive action, such as a SQL tool running a `DROP`. GitHub and GitLab Connect tools are left out too: Factory's own source-control tools enforce repository scope and self-review, and Connect's would skip both. Every user and organization on the Factory shares the project's connections, and a connection attached for another app on the same project reaches Factory sessions too. `GET /web/integrations/platform/connect-tools` and `GET /web/integrations/platform/connect-tools/tools` back the settings page.
1458
1480
 
1459
1481
  Connect caches the connection list for 30 seconds. When a later refresh fails, sessions keep the last list it got, including a connection removed since, until a refresh succeeds. A run with no list yet waits at most 15 seconds for one, then goes on without Connect tools, and Factory logs why. If the Platform stalls instead of failing, later runs also go without them until that listing answers or fails.
1460
1482
 
@@ -1470,6 +1492,8 @@ const factory = new MastraFactory({
1470
1492
  });
1471
1493
  ```
1472
1494
 
1495
+ With `tools` set, **Settings → Tools** still lists the project's connections, and says sessions get tools from code: a connection reaches sessions only if your `tools` includes it, with the tools it narrows to. Each connection's tool list shows what your `tools` gives sessions from it, and tools from no listed connection, such as MCP tools, appear under **Other tools from code**. A `tools` function that reads the request sees the signed-in user's request there, not a session's. Without Platform credentials or `MASTRA_PROJECT_ID`, the page names whichever of the two is missing.
1496
+
1473
1497
  A tool named like one Factory already gives the session, such as `linear_get_issue` from a connected Linear integration, is not offered, and Factory logs that once per name. When resolving the tools you pass throws, the run fails with that error.
1474
1498
 
1475
1499
  Factory doesn't read MCP servers from the host's `mcp.json` files, and logs a warning at startup when `~/.mastracode/mcp.json` exists. Pass MCP tools through `tools` instead:
@@ -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,0CAA0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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;AASD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC"}
@@ -331,7 +331,13 @@ function boundChangeRequestNumber(boards, item) {
331
331
  source
332
332
  })?.number;
333
333
  if (number !== void 0) return String(number);
334
- return source === "github-pr" ? /(\d+)$/.exec(item.externalSource?.externalId ?? "")?.[1] : void 0;
334
+ return source === "github-pr" ? trailingDigits(item.externalSource?.externalId ?? "") : void 0;
335
+ }
336
+ /** The run of digits ending `value`, scanned from the end so it stays linear (unlike an unanchored `/(\d+)$/`). */
337
+ function trailingDigits(value) {
338
+ let start = value.length;
339
+ while (start > 0 && value.charCodeAt(start - 1) >= 48 && value.charCodeAt(start - 1) <= 57) start--;
340
+ return start < value.length ? value.slice(start) : void 0;
335
341
  }
336
342
  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 };
337
343
 
@@ -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 {\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,U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;;;AAMA,SAAgB,yBAAyB,QAAoC,MAAgC;CAC3G,MAAM,SAAS,qBAAqB,KAAK,cAAc;CAEvD,IAAI,CADQ,kBAAkB,EAAE,OAAO,CAChC,MAAM,KAAK,OAAO,WAAW,KAAK,cAAc,QAAQ,IAAI,CAAC,CAAC,sBAAsB,KAAK,OAAO,KACrG;CAEF,MAAM,SAAS,sBAAsB;EAAE,GAAG;EAAM;CAAO,CAAC,CAAC,EAAE;CAC3D,IAAI,WAAW,KAAA,GAAW,OAAO,OAAO,MAAM;CAE9C,OAAO,WAAW,cAAc,SAAS,KAAK,KAAK,gBAAgB,cAAc,EAAE,CAAC,GAAG,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' ? trailingDigits(item.externalSource?.externalId ?? '') : undefined;\n}\n\n/** The run of digits ending `value`, scanned from the end so it stays linear (unlike an unanchored `/(\\d+)$/`). */\nfunction trailingDigits(value: string): string | undefined {\n let start = value.length;\n while (start > 0 && value.charCodeAt(start - 1) >= 48 && value.charCodeAt(start - 1) <= 57) start--;\n return start < value.length ? value.slice(start) : 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,MAAM,SAAS,aACf,MAAM,OAAO,YAAA,aACZ,MAAM,SAAS,CAAC,EAAA,CAAG,MAAK,YAAW,YAAY,IAAI;CACtD,MAAM,oBAAoB,QAAQ,MAAM,GAAG,WAAW,OAAO,OAAO,uBAAuB,CAAC,CAAC,GAAG;CAChG,MAAM,aAAa,QAAQ,MACxB,CAAC,KAAK,WACL,QAAQ,qBACR,OAAO,OAAO,+BAA+B,KAC7C,CAAC,OAAO,OAAO,uBAAuB,CAC1C,CAAC,GAAG;CACJ,MAAM,UAAU,cAAc;CAC9B,MAAM,QAAQ,UACV,QAAQ,UACL,CAAC,KAAK,WACL,MAAM,SAAS,aACf,QAAQ,qBACR,QAAQ,cACR,MAAM,iBAAiB,KAAK,OAAO,CACvC,CAAC,GAAG,KACJ,KAAA;CACJ,MAAM,YAAY,QAAQ,MAAM,aAAa,KAAK,IAAI,KAAA;CAEtD,MAAM,SAAS,QACX,QAAQ,MACL,CAAC,KAAK,WACL,MAAM,SAAS,aACf,QAAQ,SACR,MAAM,OAAO,YAAA,YACb,M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 import type { FactoryMcpConfig } from './mcp/routes.js';
37
37
  import type { FactoryMetricsOptions } from './metrics/index.js';
38
38
  import type { MastraFactorySandboxOption } from './sandbox/session-sandbox.js';
39
39
  import type { FactorySecretEncryption } from './secret-encryption.js';
40
+ import type { IdleSessionUnloadOptions } from './session/session-unloader.js';
40
41
  import type { ReviewedChangeRequest } from './session/source-control-tools.js';
41
42
  import type { IntakeEvaluator, StoredBoardInput, StoredBoardScope } from './storage/domains/boards/base.js';
42
43
  import type { FactorySandboxStart } from './workspace.js';
@@ -150,6 +151,15 @@ export interface MastraFactoryConfig {
150
151
  * (`'eager'`), so the boot overlaps the model's own latency.
151
152
  */
152
153
  sandboxStart?: FactorySandboxStart;
154
+ /**
155
+ * Unloads agent sessions from server memory once this process no longer needs them: when
156
+ * Factory stops or releases a session's sandbox, and after `idleMs` (default 30 minutes)
157
+ * without activity, checked every `sweepIntervalMs` (default 1 minute). Unloading keeps the
158
+ * thread, its messages, the session row and the sandbox; the session's next message, run or
159
+ * wake loads it again. A session running, waiting on an approval or answer, or open in a
160
+ * browser tab stays loaded. Pass `false` to keep every session loaded until it is deleted.
161
+ */
162
+ idleSessionUnload?: false | IdleSessionUnloadOptions;
153
163
  /**
154
164
  * Agent controller built-in tools (e.g. `submit_plan`) removed from every
155
165
  * Factory session, along with their prompt guidance. Use this when a custom
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,KAAK,EAAiC,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAA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