@mastra/factory 0.28.0 → 0.29.0-alpha.1
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.
- package/README.md +26 -8
- package/dist/board-changes.d.ts +16 -0
- package/dist/board-changes.d.ts.map +1 -0
- package/dist/board-changes.js +40 -0
- package/dist/board-changes.js.map +1 -0
- package/dist/boards/index.js +2 -1
- package/dist/boards/reroute.d.ts +31 -0
- package/dist/boards/reroute.d.ts.map +1 -0
- package/dist/boards/reroute.js +71 -0
- package/dist/boards/reroute.js.map +1 -0
- package/dist/boards/semantics.d.ts +1 -3
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +1 -5
- package/dist/boards/semantics.js.map +1 -1
- package/dist/environment/repository-access.d.ts +2 -0
- package/dist/environment/repository-access.d.ts.map +1 -1
- package/dist/environment/repository-access.js +9 -4
- package/dist/environment/repository-access.js.map +1 -1
- package/dist/factory.d.ts +4 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +60 -9
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +17 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/default-rules.d.ts +38 -0
- package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
- package/dist/integrations/dependabot/default-rules.js +63 -0
- package/dist/integrations/dependabot/default-rules.js.map +1 -0
- package/dist/integrations/dependabot/rules.d.ts +42 -0
- package/dist/integrations/dependabot/rules.d.ts.map +1 -0
- package/dist/integrations/dependabot/rules.js +187 -0
- package/dist/integrations/dependabot/rules.js.map +1 -0
- package/dist/integrations/dependabot/sync.d.ts +76 -0
- package/dist/integrations/dependabot/sync.d.ts.map +1 -0
- package/dist/integrations/dependabot/sync.js +111 -0
- package/dist/integrations/dependabot/sync.js.map +1 -0
- package/dist/integrations/github/pull-request-source.js +2 -1
- package/dist/integrations/github/pull-request-source.js.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +1 -1
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +7 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +5 -2
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +16 -13
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +12 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +24 -3
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +2 -1
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/discovery.d.ts +16 -0
- package/dist/integrations/gitlab/discovery.d.ts.map +1 -0
- package/dist/integrations/gitlab/discovery.js +107 -0
- package/dist/integrations/gitlab/discovery.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +1 -2
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +1 -0
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +26 -10
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/reconciler.js +4 -2
- package/dist/integrations/gitlab/reconciler.js.map +1 -1
- package/dist/integrations/gitlab/reconciliation-config.d.ts +0 -1
- package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/gitlab/reconciliation-config.js +2 -8
- package/dist/integrations/gitlab/reconciliation-config.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts +17 -0
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +28 -22
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +10 -4
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +32 -8
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/integration.d.ts +2 -1
- package/dist/integrations/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/incidentio/integration.js +7 -7
- package/dist/integrations/incidentio/integration.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts +7 -0
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +36 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/reconciliation-config.d.ts +0 -1
- package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/incidentio/reconciliation-config.js +2 -5
- package/dist/integrations/incidentio/reconciliation-config.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +24 -8
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +33 -35
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +0 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +17 -14
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/intake-discovery.d.ts +44 -0
- package/dist/integrations/intake-discovery.d.ts.map +1 -0
- package/dist/integrations/intake-discovery.js +60 -0
- package/dist/integrations/intake-discovery.js.map +1 -0
- package/dist/integrations/issue-reconcile-worker.js +1 -1
- package/dist/integrations/issue-reconcile-worker.js.map +1 -1
- package/dist/integrations/issue-reconciler.d.ts +7 -0
- package/dist/integrations/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/issue-reconciler.js +47 -12
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/integration.d.ts +3 -2
- package/dist/integrations/jira/integration.d.ts.map +1 -1
- package/dist/integrations/jira/integration.js +5 -7
- package/dist/integrations/jira/integration.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts +17 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +34 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/reconciliation-config.d.ts +0 -1
- package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/jira/reconciliation-config.js +2 -5
- package/dist/integrations/jira/reconciliation-config.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts +0 -7
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +2 -12
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +0 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +3 -13
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/kept-cards.d.ts +49 -0
- package/dist/integrations/kept-cards.d.ts.map +1 -0
- package/dist/integrations/kept-cards.js +97 -0
- package/dist/integrations/kept-cards.js.map +1 -0
- package/dist/integrations/linear/intake-discovery.d.ts +34 -0
- package/dist/integrations/linear/intake-discovery.d.ts.map +1 -0
- package/dist/integrations/linear/intake-discovery.js +112 -0
- package/dist/integrations/linear/intake-discovery.js.map +1 -0
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +1 -4
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts +13 -4
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +24 -20
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/reconciliation-config.d.ts +0 -1
- package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/linear/reconciliation-config.js +2 -8
- package/dist/integrations/linear/reconciliation-config.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +0 -2
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +3 -9
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/platform/api-client.d.ts +2 -0
- package/dist/integrations/platform/api-client.d.ts.map +1 -1
- package/dist/integrations/platform/api-client.js +6 -1
- package/dist/integrations/platform/api-client.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +8 -1
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.d.ts +17 -0
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +89 -7
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +20 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +54 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js.map +1 -1
- package/dist/integrations/platform/incidentio/integration.d.ts +3 -2
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/platform/incidentio/integration.js +7 -7
- package/dist/integrations/platform/incidentio/integration.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +4 -7
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/jira/routes.d.ts +0 -7
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +2 -12
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +2 -2
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +1 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -0
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +7 -7
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts +38 -0
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
- package/dist/integrations/platform/vanta/integration.js +149 -0
- package/dist/integrations/platform/vanta/integration.js.map +1 -0
- package/dist/integrations/reconciliation-config.d.ts +0 -1
- package/dist/integrations/reconciliation-config.d.ts.map +1 -1
- package/dist/integrations/reconciliation-config.js +1 -8
- package/dist/integrations/reconciliation-config.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +1 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/startup-summary.d.ts +8 -0
- package/dist/integrations/startup-summary.d.ts.map +1 -0
- package/dist/integrations/startup-summary.js +36 -0
- package/dist/integrations/startup-summary.js.map +1 -0
- package/dist/integrations/vanta/default-rules.d.ts +34 -0
- package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
- package/dist/integrations/vanta/default-rules.js +61 -0
- package/dist/integrations/vanta/default-rules.js.map +1 -0
- package/dist/integrations/vanta/rules.d.ts +40 -0
- package/dist/integrations/vanta/rules.d.ts.map +1 -0
- package/dist/integrations/vanta/rules.js +208 -0
- package/dist/integrations/vanta/rules.js.map +1 -0
- package/dist/integrations/vanta/sync.d.ts +40 -0
- package/dist/integrations/vanta/sync.d.ts.map +1 -0
- package/dist/integrations/vanta/sync.js +81 -0
- package/dist/integrations/vanta/sync.js.map +1 -0
- package/dist/linked-repositories-changed.d.ts +14 -0
- package/dist/linked-repositories-changed.d.ts.map +1 -0
- package/dist/linked-repositories-changed.js +48 -0
- package/dist/linked-repositories-changed.js.map +1 -0
- package/dist/mcp/routes.d.ts.map +1 -1
- package/dist/mcp/routes.js +1 -1
- package/dist/mcp/routes.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +8 -1
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +23 -2
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/contracts.d.ts +322 -0
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +202 -5
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake-routes.d.ts +3 -0
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +44 -0
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +3 -2
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/run-queue.d.ts +17 -0
- package/dist/routes/run-queue.d.ts.map +1 -0
- package/dist/routes/run-queue.js +69 -0
- package/dist/routes/run-queue.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +109 -3
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +14 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +76 -11
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-item-selection.d.ts +4 -5
- package/dist/routes/work-item-selection.d.ts.map +1 -1
- package/dist/routes/work-item-selection.js +11 -23
- package/dist/routes/work-item-selection.js.map +1 -1
- package/dist/routes/work-item-starters.d.ts.map +1 -1
- package/dist/routes/work-item-starters.js +4 -21
- package/dist/routes/work-item-starters.js.map +1 -1
- package/dist/routes/work-items.d.ts +5 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +129 -36
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatch-errors.d.ts +3 -0
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +5 -0
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +15 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +48 -20
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/index.d.ts +2 -2
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -2
- package/dist/rules/review-source-tool.js +2 -1
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +6 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +6 -2
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +3 -2
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +71 -3
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +10 -2
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +5 -0
- package/dist/rules/validation.js.map +1 -1
- package/dist/session/factory-session.d.ts +20 -5
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +20 -6
- package/dist/session/factory-session.js.map +1 -1
- package/dist/storage/domains/audit/actions.d.ts +1 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +2 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/actors.d.ts.map +1 -1
- package/dist/storage/domains/audit/actors.js +1 -1
- package/dist/storage/domains/audit/actors.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +1 -1
- package/dist/storage/domains/intake/base.js +2 -2
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +10 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +24 -2
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +32 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +54 -4
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +3 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +17 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +16 -4
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +28 -1
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/timing.d.ts +8 -1
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +10 -2
- package/dist/timing.js.map +1 -1
- package/dist/tools/approval-tools.d.ts +20 -0
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +79 -30
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +1 -1
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +1 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/read-tools.d.ts +0 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +2 -7
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +3 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +3 -3
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +14 -2
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +24 -4
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +17 -6
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +1 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +12 -2
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +1 -1
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +2 -0
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/board-filter-options.d.ts +5 -0
- package/dist/work-items/board-filter-options.d.ts.map +1 -0
- package/dist/work-items/board-filter-options.js +27 -0
- package/dist/work-items/board-filter-options.js.map +1 -0
- package/dist/work-items/board-phases.d.ts +28 -0
- package/dist/work-items/board-phases.d.ts.map +1 -0
- package/dist/work-items/board-phases.js +165 -0
- package/dist/work-items/board-phases.js.map +1 -0
- package/dist/work-items/card-facts.d.ts +24 -0
- package/dist/work-items/card-facts.d.ts.map +1 -0
- package/dist/work-items/card-facts.js +75 -0
- package/dist/work-items/card-facts.js.map +1 -0
- package/dist/work-items/card-labels.d.ts +5 -0
- package/dist/work-items/card-labels.d.ts.map +1 -0
- package/dist/work-items/card-labels.js +13 -0
- package/dist/work-items/card-labels.js.map +1 -0
- package/dist/work-items/card-number.d.ts +10 -0
- package/dist/work-items/card-number.d.ts.map +1 -0
- package/dist/work-items/card-number.js +15 -0
- package/dist/work-items/card-number.js.map +1 -0
- package/dist/work-items/card-people.d.ts +25 -0
- package/dist/work-items/card-people.d.ts.map +1 -0
- package/dist/work-items/card-people.js +100 -0
- package/dist/work-items/card-people.js.map +1 -0
- package/dist/work-items/card-search-text.d.ts +4 -0
- package/dist/work-items/card-search-text.d.ts.map +1 -0
- package/dist/work-items/card-search-text.js +15 -0
- package/dist/work-items/card-search-text.js.map +1 -0
- package/dist/work-items/card-source-filters.d.ts +23 -0
- package/dist/work-items/card-source-filters.d.ts.map +1 -0
- package/dist/work-items/card-source-filters.js +25 -0
- package/dist/work-items/card-source-filters.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +0 -6
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +2 -7
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts +4 -0
- package/dist/work-items/list-related-cards.d.ts.map +1 -0
- package/dist/work-items/list-related-cards.js +24 -0
- package/dist/work-items/list-related-cards.js.map +1 -0
- package/dist/work-items/search-words.d.ts +5 -0
- package/dist/work-items/search-words.d.ts.map +1 -0
- package/dist/work-items/search-words.js +12 -0
- package/dist/work-items/search-words.js.map +1 -0
- package/dist/work-items/source-external-id.d.ts +4 -0
- package/dist/work-items/source-external-id.d.ts.map +1 -0
- package/dist/work-items/source-external-id.js +9 -0
- package/dist/work-items/source-external-id.js.map +1 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +92 -47
- package/dist/workspace.js.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ The whole-board listing also returns a `cursor`, and each card carries `changedA
|
|
|
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.
|
|
68
|
+
|
|
67
69
|
#### Migration and dry run
|
|
68
70
|
|
|
69
71
|
Factory keeps the legacy `work_items` table and copies each card into the new tables. Before it starts serving, it copies only open cards. Done and canceled cards are copied in the background afterwards and appear on the board shortly after startup. While that runs, opening a card, or receiving a Linear, Jira, GitHub, GitLab, or incident.io event for it, copies that card on demand, so a reopened issue keeps its original card. Board lists, such as the Done column, fill in as the background copy progresses.
|
|
@@ -620,7 +622,7 @@ Boards and phases take `name` and an optional `description`. A phase lists the p
|
|
|
620
622
|
- `runner` — `{ agentId?, skill?, context?, instructions?, goal? }`. The runner is the only way a phase starts work: when a card enters the phase, from any source and including a card filed straight into it, Factory starts `skill` in the `context` session. `context` names the session the phase runs in (defaults to `work`); phases that share a context share a session. When the agent moves its own card into another phase of its context, that phase's `skill` still starts: its kickoff is queued onto the agent's run. Moving a card back into the phase it is in (a re-entry, such as a re-review after a push) supersedes the run in flight and resumes the skill. `skill` names a built-in Factory skill or one of your app's skills (see [Skills for custom boards](#skills-for-custom-boards)); a phase without one starts nothing. The kickoff names the card only by its URL (or title, quoted as untrusted data when an outside author wrote it); the agent reads everything else from the [`factory-work-item` signal](#the-factory-work-item-signal). `instructions` (up to 1,000 characters) are added to the kickoff. `agentId` defaults to `code-agent`, the only agent Factory runs today.
|
|
621
623
|
- `runner.goal` — `{ objective, maxRuns? }`: the run pursues `objective` (up to 2,000 characters) as a Mastra goal. Factory stores it on the session's thread as the run starts, with the session's model as judge, and after each run the judge decides from the objective text and the latest messages whether the work is done, should continue (Factory starts another run, up to `maxRuns`, 1–50) or is waiting for a person. Waiting leaves the goal active and the card in its phase; the next message a person sends resumes it, and a skill asks people with `ask_user`, which parks the run in Factory's attention view. When `maxRuns` runs out, the goal pauses and the card stays: resume it from the session or move the card. When the card leaves the phase, by anyone, Factory marks the goal done. The judge sees only the objective and the latest messages, so state the done and waiting criteria in the objective. Work's Building pursues the approved plan this way, with up to 20 runs.
|
|
622
624
|
- `autoStart` and `autoStartWhen` — the phase's runs start without a person's approval, for every card or only for cards matching the rule. To start only trusted authors' cards, add `author.trusted equals true` to `autoStartWhen`; by default, [intake routes](#intake-routes) file GitHub and GitLab cards from outside the write-access circle in Work › Intake, where nothing starts on its own.
|
|
623
|
-
- `exitTool` — a tool name, or `{ id, autoApprove, autoApproveWhen }`, that ends the phase. The phase holds the card until that tool succeeds (for `submit_plan`, with an approved plan) in the session that works the card there: until then an agent or board rule asking to move the card on to another working phase is rejected with `approval_required`. Once it has succeeded during the card's current visit to the phase, the agent moves the card itself with `factory_transition_work_item` (the factory-phase signal tells it so and lists `nextPhases`), or a board tool rule for the exit tool (`tools`) moves it; the tool's success never moves the card by itself. A person can move the card at any time. The phase needs at least one next phase. `autoApprove` and `autoApproveWhen` only decide whether the tool approves itself, for every card or only cards matching the rule, or waits for a person; they are the only way plans are approved without a person. Factory sessions already run tools without asking, so for `submit_plan` this means an auto-approved plan is accepted without a person. Work's Planning declares `{ id: 'submit_plan', autoApprove: false }`: every plan waits for a person, who approves `submit_plan` in a signed-in chat (or moves the card), and then `factory-plan` moves the card to Building.
|
|
625
|
+
- `exitTool` — a tool name, or `{ id, autoApprove, autoApproveWhen }`, that ends the phase. The phase holds the card until that tool succeeds (for `submit_plan`, with an approved plan) in the session that works the card there: until then an agent or board rule asking to move the card on to another working phase is rejected with `approval_required`. Once it has succeeded during the card's current visit to the phase, the agent moves the card itself with `factory_transition_work_item` (the factory-phase signal tells it so and lists `nextPhases`), or a board tool rule for the exit tool (`tools`) moves it; the tool's success never moves the card by itself. A person can move the card at any time. The phase needs at least one next phase. `autoApprove` and `autoApproveWhen` only decide whether the tool approves itself, for every card or only cards matching the rule, or waits for a person; they are the only way plans are approved without a person. Factory sessions already run tools without asking, so for `submit_plan` this means an auto-approved plan is accepted without a person. Any other exit tool that pauses for a yes or no is approved the same way, and the sessions following the card are told a run waits on them only when a person has to answer. Work's Planning declares `{ id: 'submit_plan', autoApprove: false }`: every plan waits for a person, who approves `submit_plan` in a signed-in chat (or moves the card), and then `factory-plan` moves the card to Building.
|
|
624
626
|
- `tools` — Factory tools the phase gives the session that works the card in it (the session whose context is the phase's `runner.context`): `factory_record_review_verdict` and `factory_review_source`. Tools follow the card: when it moves to a phase without them, the session loses them on its next turn, and a verdict tool call made after the card moved is refused. Every bound session keeps `factory_transition_work_item`. Work's Review grants both; a self-review phase, on a board that has one, grants only the verdict tool.
|
|
625
627
|
|
|
626
628
|
Rules test a card's facts, read from its work item as the provider reported it:
|
|
@@ -674,6 +676,22 @@ const releaseBoard = defineBoard({
|
|
|
674
676
|
|
|
675
677
|
**Migration:** `defineBoard()` still accepts the old field names and maps them to the new ones straight away: `title` → `name`, `role` → `runner.context`, `next` → `nextPhases`. It logs one warning per board that still uses them. Setting both `title` and `name`, or `role` and `runner.context`, to different values is rejected. `outcomes`, `onEnter` and `onExit` are ignored (see [Board lifecycle rules](#board-lifecycle-rules)); outcome targets are added to `nextPhases`. The board `defineBoard()` returns still has the old names as read-only copies — `board.title` and `phase.title` equal `name`, a working phase's `role` equals `runner.context`, and `phase.next` is set when the phase declared `next` — so code that reads them, or passes a defined board's phases to `defineBoard()` again, keeps working. They are deprecated; read `name`, `runner.context` and `nextPhases` instead. The board catalog (`GET /web/factory/projects/:id/boards`) still sends `title` and `role` beside the new fields for older clients. Card session keys do not change: a phase's context is its old role.
|
|
676
678
|
|
|
679
|
+
### Run cap and the run queue
|
|
680
|
+
|
|
681
|
+
Each server process runs at most 10 automated runs at once. A run is a skill or prompt started on a card (`invokeSkill`), a message sent to a card's session (`sendMessage`), or pull request activity delivered to one (`signalActivity`). Runs past the cap wait, oldest first, until a slot frees. Raise or lower the cap with `dispatcher.maxInFlight`, or `MASTRACODE_DISPATCH_MAX_IN_FLIGHT` in the Mastra Code web server:
|
|
682
|
+
|
|
683
|
+
```ts
|
|
684
|
+
const factory = new MastraFactory({ storage, dispatcher: { maxInFlight: 25 } });
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
The cap counts per process, not per deployment: three replicas with the default run up to 30 at once.
|
|
688
|
+
|
|
689
|
+
The board shows how many automated runs are waiting, and opens a list of them, oldest first. A waiting card reads `Queued (#3)`. Manual starts take the same slots and are claimed ahead of these runs, but are not listed. `GET /web/factory/projects/:id/run-queue` returns the same data:
|
|
690
|
+
|
|
691
|
+
- `slots` — this server's `inUse` and `cap`, or `null` when it runs no dispatcher. Other replicas keep their own.
|
|
692
|
+
- `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`.
|
|
693
|
+
- `queuedCount` and `queued` — every automated run waiting for a slot, and the oldest 50 with their `position`, card, phase and the skill they will run. A retry still backing off is not waiting yet.
|
|
694
|
+
|
|
677
695
|
### The `factory-work-item` signal
|
|
678
696
|
|
|
679
697
|
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.
|
|
@@ -847,10 +865,10 @@ Custom phase signals and persisted tool-result ingestion use the item's installe
|
|
|
847
865
|
|
|
848
866
|
### Choose which sources feed a project
|
|
849
867
|
|
|
850
|
-
Intake bindings are explicit. A Linear project, Jira project, GitLab project, incident.io source or GitHub repository
|
|
868
|
+
Intake bindings are explicit. A Linear project, Jira project, GitLab project, incident.io source or GitHub repository only feeds a Factory project once it is bound to it. The server files its items as cards; the board and search read only those cards and never ask a provider for its list, so nothing is filed just by opening a board. A binding decides only which project a source feeds. Where its cards land is up to the project's [intake routes](#intake-routes): a new card is filed in the default board's first phase, and the first route that matches it places it. To send one repository, Linear team or Jira project to its own board, add a route with a `source.repository` condition. A route sees where an item lives, not which binding brought it in: two Linear projects in the same team share the team key, so a route can't send them to different boards.
|
|
851
869
|
|
|
852
870
|
- **Linear:** each project binding feeds one Factory project.
|
|
853
|
-
- **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.
|
|
871
|
+
- **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.
|
|
854
872
|
- **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.
|
|
855
873
|
|
|
856
874
|
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.
|
|
@@ -1163,7 +1181,7 @@ With no constructor options, the integration reads `GITLAB_ACCESS_TOKEN`, `GITLA
|
|
|
1163
1181
|
|
|
1164
1182
|
`GITLAB_BASE_URL` must use HTTPS. Plain HTTP is accepted only for loopback development instances (`localhost`, `127.0.0.0/8`, or `::1`), where the access token is sent without transport encryption.
|
|
1165
1183
|
|
|
1166
|
-
Linking a GitLab repository imports its open issues and merge requests (up to five pages each). Without a webhook,
|
|
1184
|
+
Linking a GitLab repository imports its open issues and merge requests (up to five pages each). Without a webhook, the reconcile sweep discovers later items and records changed merge-request heads: every five minutes by default (`MASTRACODE_GITLAB_RECONCILE_INTERVAL_MS`), it lists the open, non-draft merge requests of each linked repository and the issues of each selected source routed to a Factory, up to five pages each, whether or not a board is open. Requesting a list never files a card. The same sweep reconciles existing cards. For ongoing issue changes, comments, and merge-request lifecycle events, configure the direct project webhook with `GITLAB_WEBHOOK_SECRET`.
|
|
1167
1185
|
|
|
1168
1186
|
For a Mastra Platform/Nango connection, use `PlatformGitLabIntegration`. `MastraFactory` installs it automatically whenever Platform credentials are configured and no integration with id `gitlab` was supplied. It discovers every active connection of the organization on the Platform's `gitlab` (OAuth) integration, proxies provider requests through `/v2/connections/{connectionId}/proxy`, and polls the Platform event log for GitLab events. `MASTRA_GITLAB_CONNECTION_ID` (or the `connectionId` constructor option) is optional and only narrows discovery to one connection. An explicit integration with id `gitlab` takes precedence.
|
|
1169
1187
|
|
|
@@ -1201,7 +1219,7 @@ import { PlatformIncidentioIntegration } from '@mastra/factory/integrations/plat
|
|
|
1201
1219
|
const incidentio = new PlatformIncidentioIntegration(); // Reads Platform credentials from the environment.
|
|
1202
1220
|
```
|
|
1203
1221
|
|
|
1204
|
-
Both integrations expose incidents and incident follow-ups as separate Intake sources. Their provider-neutral Intake items can be imported onto any installed board, including custom boards. A reconciliation worker
|
|
1222
|
+
Both integrations expose incidents and incident follow-ups as separate Intake sources. Their provider-neutral Intake items can be imported onto any installed board, including custom boards. A reconciliation worker runs every five minutes by default: it refreshes the provider state and metadata of imported incidents and follow-ups, and files a work item for each new follow-up in a source bound to a Factory project. incident.io lists follow-ups oldest first and cannot filter them by status, so the sweep reads every page of each bound source. Opening a board only reads the list. Set `MASTRACODE_INCIDENT_IO_RECONCILE_INTERVAL_MS` to a positive millisecond interval to change its cadence. Follow-up state updates map Factory completion and cancellation to incident.io's `completed` and `not_doing` statuses. incident.io does not expose Intake comments through these adapters.
|
|
1205
1223
|
|
|
1206
1224
|
### Linear workspace connections
|
|
1207
1225
|
|
|
@@ -1282,7 +1300,7 @@ Read tools and `factory_message_origin` are available on every turn. The other t
|
|
|
1282
1300
|
|
|
1283
1301
|
`factory_switch_session_model` changes the model of a side, work item or review session you own in the same Factory, without recreating it. It refuses a model this server can't run. A running session switches right away; a stopped one uses the model on its next run.
|
|
1284
1302
|
|
|
1285
|
-
`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 the Factory links more than one: a run can't start on a card that doesn't say which. `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`. 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.
|
|
1303
|
+
`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 the Factory links more than one: a run can't start on a card that doesn't say which. `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.
|
|
1286
1304
|
|
|
1287
1305
|
#### Messaging between sessions
|
|
1288
1306
|
|
|
@@ -1299,7 +1317,7 @@ How a message is delivered depends on its priority. `urgent` always delivers, ev
|
|
|
1299
1317
|
- **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.
|
|
1300
1318
|
- **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, and refuses an item linked to several repositories. 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.
|
|
1301
1319
|
|
|
1302
|
-
|
|
1320
|
+
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.
|
|
1303
1321
|
|
|
1304
1322
|
#### Reports
|
|
1305
1323
|
|
|
@@ -1317,7 +1335,7 @@ Progress reports from one session replace each other while unread. `done`, `fail
|
|
|
1317
1335
|
|
|
1318
1336
|
Every run of a work session or side session ends with exactly one final report, however the run started: the board, a person typing into the session, a wake from another session's message, or a run after a server restart. Each Factory session gets a listener when it is created. A session with an active run binding reports to everyone following its work item, including for the run that moved the item to a finished stage and so ended its own binding; a side session reports to the session that started it; a person's own session reports to nobody. When a run ends, Factory checks each recipient's thread for a final report the agent sent since the run started, and sends one itself to the recipients that lack it: `done` when the run completed, `failed` when it ended in error (quoting the error), and `blocked`, naming the tool, when the run stopped waiting for an answer or for someone to approve a tool call. A reply with a final `status` counts as the final report, and any reply counts for a completed run. A run that completes after the agent reported `blocked` is waiting for an answer, so it gets no `done`; a run someone stopped gets no report. A board run that fails before it ever runs (no session, a configuration the run can't succeed with) reports `failed` once no retry remains. These backstop reports carry a `backstop` attribute.
|
|
1319
1337
|
|
|
1320
|
-
A run that holds a tool call for approval stays open, so the same listener tells those sessions right away: an urgent `approval` notification names the session, the tool, its arguments and the `toolCallId`, once per call. A session that follows the work item, or started the side session, can answer it with `factory_answer_approval`, as the person signed in to it; the answer is audited as `factory.run.approved` or `factory.run.dismissed`. Other people's private sessions can't be answered, and an approval whose run already ended can't be either: the tool says so, and the session can be messaged to try again.
|
|
1338
|
+
A run that holds a tool call for approval stays open, so the same listener tells those sessions right away: an urgent `approval` notification names the session, the tool, its arguments and the `toolCallId`, once per call. A session that follows the work item, or started the side session, can answer it with `factory_answer_approval`, as the person signed in to it; the answer is audited as `factory.run.approved` or `factory.run.dismissed`. A tool that pauses itself for a bare yes or no, such as `submit_plan`, ends the run instead: the `blocked` report then names the session and the `toolCallId` to approve or decline the same way, while a tool that needs a typed answer is answered in its session. Whoever answers, the run carries on as the session's owner. Other people's private sessions can't be answered, and an approval whose run already ended can't be either: the tool says so, and the session can be messaged to try again.
|
|
1321
1339
|
|
|
1322
1340
|
When a followed work item changes stage, subscribers whose session is running get a `low` priority `stage` notice. A stage change never wakes an offline session; it sees the current stage in its state signal instead.
|
|
1323
1341
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PubSub } from '@mastra/core/events';
|
|
2
|
+
/** One topic for every project, so a replica hears about all boards through one subscription. */
|
|
3
|
+
export declare const BOARD_CHANGES_TOPIC = "factory.board-changes";
|
|
4
|
+
export interface BoardChangeScope {
|
|
5
|
+
orgId: string;
|
|
6
|
+
factoryProjectId: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tells other replicas that a project's board changed. Never awaited — a slow
|
|
10
|
+
* or dead broker must not hold up the write it describes. `origin` lets the
|
|
11
|
+
* publishing replica skip its own echo; it already handled the change.
|
|
12
|
+
*/
|
|
13
|
+
export declare function publishBoardChange(pubsub: PubSub, origin: string, scope: BoardChangeScope): void;
|
|
14
|
+
/** Hears board changes made on other replicas; resolves to the unsubscribe. */
|
|
15
|
+
export declare function subscribeBoardChanges(pubsub: PubSub, origin: string, changed: (scope: BoardChangeScope) => void): Promise<() => Promise<void>>;
|
|
16
|
+
//# sourceMappingURL=board-changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-changes.d.ts","sourceRoot":"","sources":["../src/board-changes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGjE,iGAAiG;AACjG,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAahG;AAED,+EAA+E;AAC/E,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACzC,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAS9B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { withAck } from "@mastra/core/events";
|
|
2
|
+
// src/board-changes.ts
|
|
3
|
+
/** One topic for every project, so a replica hears about all boards through one subscription. */
|
|
4
|
+
const BOARD_CHANGES_TOPIC = "factory.board-changes";
|
|
5
|
+
/**
|
|
6
|
+
* Tells other replicas that a project's board changed. Never awaited — a slow
|
|
7
|
+
* or dead broker must not hold up the write it describes. `origin` lets the
|
|
8
|
+
* publishing replica skip its own echo; it already handled the change.
|
|
9
|
+
*/
|
|
10
|
+
function publishBoardChange(pubsub, origin, scope) {
|
|
11
|
+
pubsub.publish(BOARD_CHANGES_TOPIC, {
|
|
12
|
+
type: "factory.board.changed",
|
|
13
|
+
runId: origin,
|
|
14
|
+
data: {
|
|
15
|
+
orgId: scope.orgId,
|
|
16
|
+
factoryProjectId: scope.factoryProjectId
|
|
17
|
+
}
|
|
18
|
+
}).catch((error) => {
|
|
19
|
+
console.warn("[Factory] Failed to publish a board change", {
|
|
20
|
+
factoryProjectId: scope.factoryProjectId,
|
|
21
|
+
error: error instanceof Error ? error.message : String(error)
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Hears board changes made on other replicas; resolves to the unsubscribe. */
|
|
26
|
+
async function subscribeBoardChanges(pubsub, origin, changed) {
|
|
27
|
+
const onEvent = withAck(async (event) => {
|
|
28
|
+
if (event.runId === origin) return;
|
|
29
|
+
const { orgId, factoryProjectId } = event.data ?? {};
|
|
30
|
+
if (typeof orgId === "string" && typeof factoryProjectId === "string") changed({
|
|
31
|
+
orgId,
|
|
32
|
+
factoryProjectId
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
await pubsub.subscribe(BOARD_CHANGES_TOPIC, onEvent, { startFrom: "latest" });
|
|
36
|
+
return () => pubsub.unsubscribe(BOARD_CHANGES_TOPIC, onEvent);
|
|
37
|
+
}
|
|
38
|
+
export { BOARD_CHANGES_TOPIC, publishBoardChange, subscribeBoardChanges };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=board-changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-changes.js","names":[],"sources":["../src/board-changes.ts"],"sourcesContent":["import type { EventCallback, PubSub } from '@mastra/core/events';\nimport { withAck } from '@mastra/core/events';\n\n/** One topic for every project, so a replica hears about all boards through one subscription. */\nexport const BOARD_CHANGES_TOPIC = 'factory.board-changes';\n\nexport interface BoardChangeScope {\n orgId: string;\n factoryProjectId: string;\n}\n\n/**\n * Tells other replicas that a project's board changed. Never awaited — a slow\n * or dead broker must not hold up the write it describes. `origin` lets the\n * publishing replica skip its own echo; it already handled the change.\n */\nexport function publishBoardChange(pubsub: PubSub, origin: string, scope: BoardChangeScope): void {\n pubsub\n .publish(BOARD_CHANGES_TOPIC, {\n type: 'factory.board.changed',\n runId: origin,\n data: { orgId: scope.orgId, factoryProjectId: scope.factoryProjectId },\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a board change', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n\n/** Hears board changes made on other replicas; resolves to the unsubscribe. */\nexport async function subscribeBoardChanges(\n pubsub: PubSub,\n origin: string,\n changed: (scope: BoardChangeScope) => void,\n): Promise<() => Promise<void>> {\n const onEvent: EventCallback = withAck(async event => {\n if (event.runId === origin) return;\n const { orgId, factoryProjectId } = (event.data ?? {}) as Partial<BoardChangeScope>;\n if (typeof orgId === 'string' && typeof factoryProjectId === 'string') changed({ orgId, factoryProjectId });\n });\n // Without `latest`, a retaining broker replays changes made before this replica read anything.\n await pubsub.subscribe(BOARD_CHANGES_TOPIC, onEvent, { startFrom: 'latest' });\n return () => pubsub.unsubscribe(BOARD_CHANGES_TOPIC, onEvent);\n}\n"],"mappings":";;;AAIA,MAAa,sBAAsB;;;;;;AAYnC,SAAgB,mBAAmB,QAAgB,QAAgB,OAA+B;CAChG,OACG,QAAQ,qBAAqB;EAC5B,MAAM;EACN,OAAO;EACP,MAAM;GAAE,OAAO,MAAM;GAAO,kBAAkB,MAAM;EAAiB;CACvE,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,8CAA8C;GACzD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL;;AAGA,eAAsB,sBACpB,QACA,QACA,SAC8B;CAC9B,MAAM,UAAyB,QAAQ,OAAM,UAAS;EACpD,IAAI,MAAM,UAAU,QAAQ;EAC5B,MAAM,EAAE,OAAO,qBAAsB,MAAM,QAAQ,CAAC;EACpD,IAAI,OAAO,UAAU,YAAY,OAAO,qBAAqB,UAAU,QAAQ;GAAE;GAAO;EAAiB,CAAC;CAC5G,CAAC;CAED,MAAM,OAAO,UAAU,qBAAqB,SAAS,EAAE,WAAW,SAAS,CAAC;CAC5E,aAAa,OAAO,YAAY,qBAAqB,OAAO;AAC9D"}
|
package/dist/boards/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, REVIEW_CONTEXT, defineBoard } from "./define-board.js";
|
|
2
2
|
import { DEFAULT_BOARD_ID } from "./default-board.js";
|
|
3
3
|
import { cardRuleFacts } from "./card-facts.js";
|
|
4
|
-
import { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField,
|
|
4
|
+
import { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, withBoardClosure, withBoardFlow, withIntakeTarget, workItemPhaseSemantics } from "./semantics.js";
|
|
5
|
+
import { sourceExternalId } from "../work-items/source-external-id.js";
|
|
5
6
|
import { boardRegistryOf, createBoardRegistry, defaultBoards } from "./registry.js";
|
|
6
7
|
import { workBoard } from "./work.js";
|
|
7
8
|
export { BoardDefinitionError, DEFAULT_BOARD_ID, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, REVIEW_CONTEXT, awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boardRegistryOf, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, cardRuleFacts, createBoardRegistry, defaultBoards, defineBoard, eventBoardId, hasPullRequest, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workBoard, workItemPhaseSemantics };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';
|
|
2
|
+
import type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
3
|
+
import type { BoardRegistry } from './registry.js';
|
|
4
|
+
export type RerouteMove = {
|
|
5
|
+
item: Card;
|
|
6
|
+
fromBoard: string;
|
|
7
|
+
toBoard: string;
|
|
8
|
+
toPhase: string;
|
|
9
|
+
routeId: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Which untouched cards the routes, as they stand, would file on a different board. Each lands at
|
|
13
|
+
* the start of its new board. A card no route places stays where it is.
|
|
14
|
+
*/
|
|
15
|
+
export declare function planReroute(routes: readonly StoredIntakeRouteRecord[], items: readonly Card[], registry: BoardRegistry): RerouteMove[];
|
|
16
|
+
/** How many cards a plan moves from each board to each other board. */
|
|
17
|
+
export declare function summarizeReroute(moves: readonly RerouteMove[]): {
|
|
18
|
+
fromBoard: string;
|
|
19
|
+
toBoard: string;
|
|
20
|
+
count: number;
|
|
21
|
+
}[];
|
|
22
|
+
export declare function applyReroute({ moves, workItems, registry, userId, }: {
|
|
23
|
+
moves: readonly RerouteMove[];
|
|
24
|
+
workItems: Pick<WorkItemsStorage, 'update' | 'supersedeDecisionsForWorkItem'>;
|
|
25
|
+
registry: BoardRegistry;
|
|
26
|
+
userId: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
moved: number;
|
|
29
|
+
skipped: number;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=reroute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reroute.d.ts","sourceRoot":"","sources":["../../src/boards/reroute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAY/G;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,uBAAuB,EAAE,EAC1C,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,aAAa,GACtB,WAAW,EAAE,CAYf;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,WAAW,EAAE,GAC5B;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CASzD;AAED,wBAAsB,YAAY,CAAC,EACjC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,+BAA+B,CAAC,CAAC;IAC9E,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB9C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { cardRuleFacts } from "./card-facts.js";
|
|
2
|
+
import { resolveIntakePlacement } from "./intake-routing.js";
|
|
3
|
+
import { effectiveBoard, moveCardToBoard } from "./relocate.js";
|
|
4
|
+
// src/boards/reroute.ts
|
|
5
|
+
/**
|
|
6
|
+
* A card nobody has worked yet: it sits alone in its board's first phase with no session on it.
|
|
7
|
+
* Only such cards follow a change to the intake routes; anything further along stays put.
|
|
8
|
+
*/
|
|
9
|
+
function untouched(item, registry) {
|
|
10
|
+
const board = registry.get(effectiveBoard(item));
|
|
11
|
+
if (!board) return false;
|
|
12
|
+
return item.stages.length === 1 && item.stages[0] === board.initialPhase && Object.keys(item.sessions).length === 0;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Which untouched cards the routes, as they stand, would file on a different board. Each lands at
|
|
16
|
+
* the start of its new board. A card no route places stays where it is.
|
|
17
|
+
*/
|
|
18
|
+
function planReroute(routes, items, registry) {
|
|
19
|
+
const moves = [];
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
if (!untouched(item, registry)) continue;
|
|
22
|
+
const placement = resolveIntakePlacement(routes, cardRuleFacts(item), registry);
|
|
23
|
+
if (!placement) continue;
|
|
24
|
+
const fromBoard = effectiveBoard(item);
|
|
25
|
+
if (placement.board === fromBoard) continue;
|
|
26
|
+
const target = registry.get(placement.board);
|
|
27
|
+
moves.push({
|
|
28
|
+
item,
|
|
29
|
+
fromBoard,
|
|
30
|
+
toBoard: placement.board,
|
|
31
|
+
toPhase: target.initialPhase,
|
|
32
|
+
routeId: placement.routeId
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return moves;
|
|
36
|
+
}
|
|
37
|
+
/** How many cards a plan moves from each board to each other board. */
|
|
38
|
+
function summarizeReroute(moves) {
|
|
39
|
+
const counts = /* @__PURE__ */ new Map();
|
|
40
|
+
for (const { fromBoard, toBoard } of moves) {
|
|
41
|
+
const key = `${fromBoard}\u0000${toBoard}`;
|
|
42
|
+
const entry = counts.get(key) ?? {
|
|
43
|
+
fromBoard,
|
|
44
|
+
toBoard,
|
|
45
|
+
count: 0
|
|
46
|
+
};
|
|
47
|
+
entry.count += 1;
|
|
48
|
+
counts.set(key, entry);
|
|
49
|
+
}
|
|
50
|
+
return [...counts.values()];
|
|
51
|
+
}
|
|
52
|
+
async function applyReroute({ moves, workItems, registry, userId }) {
|
|
53
|
+
let moved = 0;
|
|
54
|
+
let skipped = 0;
|
|
55
|
+
for (const move of moves) if (await moveCardToBoard({
|
|
56
|
+
workItems,
|
|
57
|
+
boardRegistry: registry,
|
|
58
|
+
userId,
|
|
59
|
+
item: move.item,
|
|
60
|
+
targetBoard: move.toBoard,
|
|
61
|
+
targetStage: move.toPhase
|
|
62
|
+
}) === "moved") moved += 1;
|
|
63
|
+
else skipped += 1;
|
|
64
|
+
return {
|
|
65
|
+
moved,
|
|
66
|
+
skipped
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export { applyReroute, planReroute, summarizeReroute };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=reroute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reroute.js","names":[],"sources":["../../src/boards/reroute.ts"],"sourcesContent":["import type { StoredIntakeRouteRecord } from '../storage/domains/boards/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { cardRuleFacts } from './card-facts.js';\nimport { resolveIntakePlacement } from './intake-routing.js';\nimport type { BoardRegistry } from './registry.js';\nimport { effectiveBoard, moveCardToBoard } from './relocate.js';\n\nexport type RerouteMove = { item: Card; fromBoard: string; toBoard: string; toPhase: string; routeId: string };\n\n/**\n * A card nobody has worked yet: it sits alone in its board's first phase with no session on it.\n * Only such cards follow a change to the intake routes; anything further along stays put.\n */\nfunction untouched(item: Card, registry: BoardRegistry): boolean {\n const board = registry.get(effectiveBoard(item));\n if (!board) return false;\n return item.stages.length === 1 && item.stages[0] === board.initialPhase && Object.keys(item.sessions).length === 0;\n}\n\n/**\n * Which untouched cards the routes, as they stand, would file on a different board. Each lands at\n * the start of its new board. A card no route places stays where it is.\n */\nexport function planReroute(\n routes: readonly StoredIntakeRouteRecord[],\n items: readonly Card[],\n registry: BoardRegistry,\n): RerouteMove[] {\n const moves: RerouteMove[] = [];\n for (const item of items) {\n if (!untouched(item, registry)) continue;\n const placement = resolveIntakePlacement(routes, cardRuleFacts(item), registry);\n if (!placement) continue;\n const fromBoard = effectiveBoard(item);\n if (placement.board === fromBoard) continue;\n const target = registry.get(placement.board)!;\n moves.push({ item, fromBoard, toBoard: placement.board, toPhase: target.initialPhase, routeId: placement.routeId });\n }\n return moves;\n}\n\n/** How many cards a plan moves from each board to each other board. */\nexport function summarizeReroute(\n moves: readonly RerouteMove[],\n): { fromBoard: string; toBoard: string; count: number }[] {\n const counts = new Map<string, { fromBoard: string; toBoard: string; count: number }>();\n for (const { fromBoard, toBoard } of moves) {\n const key = `${fromBoard}\\u0000${toBoard}`;\n const entry = counts.get(key) ?? { fromBoard, toBoard, count: 0 };\n entry.count += 1;\n counts.set(key, entry);\n }\n return [...counts.values()];\n}\n\nexport async function applyReroute({\n moves,\n workItems,\n registry,\n userId,\n}: {\n moves: readonly RerouteMove[];\n workItems: Pick<WorkItemsStorage, 'update' | 'supersedeDecisionsForWorkItem'>;\n registry: BoardRegistry;\n userId: string;\n}): Promise<{ moved: number; skipped: number }> {\n let moved = 0;\n let skipped = 0;\n for (const move of moves) {\n const result = await moveCardToBoard({\n workItems,\n boardRegistry: registry,\n userId,\n item: move.item,\n targetBoard: move.toBoard,\n targetStage: move.toPhase,\n });\n if (result === 'moved') moved += 1;\n else skipped += 1;\n }\n return { moved, skipped };\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAAY,UAAkC;CAC/D,MAAM,QAAQ,SAAS,IAAI,eAAe,IAAI,CAAC;CAC/C,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK,OAAO,OAAO,MAAM,gBAAgB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,WAAW;AACpH;;;;;AAMA,SAAgB,YACd,QACA,OACA,UACe;CACf,MAAM,QAAuB,CAAC;CAC9B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,UAAU,MAAM,QAAQ,GAAG;EAChC,MAAM,YAAY,uBAAuB,QAAQ,cAAc,IAAI,GAAG,QAAQ;EAC9E,IAAI,CAAC,WAAW;EAChB,MAAM,YAAY,eAAe,IAAI;EACrC,IAAI,UAAU,UAAU,WAAW;EACnC,MAAM,SAAS,SAAS,IAAI,UAAU,KAAK;EAC3C,MAAM,KAAK;GAAE;GAAM;GAAW,SAAS,UAAU;GAAO,SAAS,OAAO;GAAc,SAAS,UAAU;EAAQ,CAAC;CACpH;CACA,OAAO;AACT;;AAGA,SAAgB,iBACd,OACyD;CACzD,MAAM,yBAAS,IAAI,IAAmE;CACtF,KAAK,MAAM,EAAE,WAAW,aAAa,OAAO;EAC1C,MAAM,MAAM,GAAG,UAAU,QAAQ;EACjC,MAAM,QAAQ,OAAO,IAAI,GAAG,KAAK;GAAE;GAAW;GAAS,OAAO;EAAE;EAChE,MAAM,SAAS;EACf,OAAO,IAAI,KAAK,KAAK;CACvB;CACA,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;AAC5B;AAEA,eAAsB,aAAa,EACjC,OACA,WACA,UACA,UAM8C;CAC9C,IAAI,QAAQ;CACZ,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OASjB,IAAI,MARiB,gBAAgB;EACnC;EACA,eAAe;EACf;EACA,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,aAAa,KAAK;CACpB,CAAC,MACc,SAAS,SAAS;MAC5B,WAAW;CAElB,OAAO;EAAE;EAAO;CAAQ;AAC1B"}
|
|
@@ -91,8 +91,6 @@ export declare function pullRequestSources(item: SourcedItem): WorkItemSourceRow
|
|
|
91
91
|
export declare function hasPullRequest(item: SourcedItem & {
|
|
92
92
|
readonly source?: string;
|
|
93
93
|
}): boolean;
|
|
94
|
-
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
95
|
-
export declare function sourceExternalId(source: Pick<WorkItemSourceRow, 'sourceType' | 'workspaceId' | 'externalId'>): string;
|
|
96
94
|
/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
|
|
97
95
|
export declare function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined;
|
|
98
96
|
/**
|
|
@@ -224,5 +222,5 @@ export declare function rulePhaseField(boards: Pick<BoardRegistry, 'get'>, item:
|
|
|
224
222
|
* or, for an issue card in its board's pull request review phase, the pull request attached to it.
|
|
225
223
|
*/
|
|
226
224
|
export declare function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined;
|
|
227
|
-
export {};
|
|
225
|
+
export { sourceExternalId } from '../work-items/source-external-id.js';
|
|
228
226
|
//# sourceMappingURL=semantics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../../src/boards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,CACpC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD,cAAc,GAAG,SAAS,CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,oBAAoB,CAS3F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD,uBAAuB,GAAG,SAAS,CAUrC;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,YAAY,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG5C;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG9C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAU3G;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC"}
|
package/dist/boards/semantics.js
CHANGED
|
@@ -3,6 +3,7 @@ import "./default-board.js";
|
|
|
3
3
|
import "./define-board.js";
|
|
4
4
|
import { reviewBoard } from "./review.js";
|
|
5
5
|
import { workBoard } from "./work.js";
|
|
6
|
+
import { sourceExternalId } from "../work-items/source-external-id.js";
|
|
6
7
|
// src/boards/semantics.ts
|
|
7
8
|
/**
|
|
8
9
|
* Board that owns a work item. Rows created before boards were persisted carry no `board`;
|
|
@@ -138,11 +139,6 @@ function pullRequestSources(item) {
|
|
|
138
139
|
function hasPullRequest(item) {
|
|
139
140
|
return item.source !== void 0 && isPullRequestCard({ source: item.source }) || pullRequestSources(item).length > 0;
|
|
140
141
|
}
|
|
141
|
-
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
142
|
-
function sourceExternalId(source) {
|
|
143
|
-
const prefix = `${source.sourceType}:${source.workspaceId ? `${source.workspaceId}:` : ""}`;
|
|
144
|
-
return source.externalId.startsWith(prefix) ? source.externalId.slice(prefix.length) : source.externalId;
|
|
145
|
-
}
|
|
146
142
|
/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
|
|
147
143
|
function pullRequestSourceNumber(source) {
|
|
148
144
|
const metadata = source.metadata ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantics.js","names":[],"sources":["../../src/boards/semantics.ts"],"sourcesContent":["import type {\n FactoryRuleBoardClosure,\n FactoryRuleBoardFlow,\n FactoryRuleIntakeTarget,\n FactoryRulePhaseContext,\n} from '../rules/types.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport type { MetricsPhaseOutcomes } from '../storage/domains/work-items/metrics.js';\nimport type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\nimport { workItemBranch, workItemBranchSource } from '../work-item-branch.js';\nimport { DEFAULT_BOARD_ID } from './default-board.js';\nimport { REVIEW_CONTEXT } from './define-board.js';\nimport type {\n BoardEventIntegration,\n BoardEventRules,\n BoardPhase,\n BoardPhaseKind,\n BoardToolResultRuleHandler,\n} from './define-board.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { workBoard } from './work.js';\n\nexport interface PhaseSemantics {\n readonly kind: BoardPhaseKind;\n /** Seat that carries a working phase; absent for resting and terminal phases. */\n readonly role?: string;\n}\n\n/**\n * Board that owns a work item. Rows created before boards were persisted carry no `board`;\n * they belong to the default board. (Pull requests used to default to the retired Review board;\n * storage reads those rows as the default board, and keeps cards stored on Review there only in a\n * project that still uses it.)\n */\nexport function boardForWorkItem(item: Pick<Card, 'board'>): string {\n return item.board ?? DEFAULT_BOARD_ID;\n}\n\nconst flows = new WeakMap<object, FactoryRuleBoardFlow>();\n\n/**\n * The phases a board's pull request loop runs through, read from what each phase declares\n * rather than from its key:\n *\n * Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat\n * that records verdicts.\n *\n * - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull\n * requests: a pull request's own card is reviewed there, an attached pull request is reviewed\n * there, verdicts on pull requests are recorded there, and a push or review request re-enters it.\n * - `selfReview`: the first working phase that grants `factory_record_review_verdict` without\n * `factory_review_source`: an independent review of the builder's branch before a pull request.\n * - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs\n * in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that\n * builds nothing has no triage phase.\n * - `build`: the last working phase, in declaration order, that is neither of those and can move\n * into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends\n * requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.\n *\n * A board without a `factory_review_source` phase has no pull request loop.\n */\nexport function boardFlow(board: InstalledBoard | undefined): FactoryRuleBoardFlow {\n if (!board) return Object.freeze({});\n const cached = flows.get(board);\n if (cached) return cached;\n const entries = Object.entries(board.phases) as [string, BoardPhase<string>][];\n const grants = (phase: BoardPhase<string>, tool: string) =>\n phase.kind === 'working' &&\n phase.runner.context === REVIEW_CONTEXT &&\n (phase.tools ?? []).some(granted => granted === tool);\n const pullRequestReview = entries.find(([, phase]) => grants(phase, 'factory_review_source'))?.[0];\n const selfReview = entries.find(\n ([key, phase]) =>\n key !== pullRequestReview &&\n grants(phase, 'factory_record_review_verdict') &&\n !grants(phase, 'factory_review_source'),\n )?.[0];\n const handoff = selfReview ?? pullRequestReview;\n const build = handoff\n ? entries.findLast(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== pullRequestReview &&\n key !== selfReview &&\n board.allowsTransition(key, handoff),\n )?.[0]\n : undefined;\n const buildRole = build ? board.roleForPhase(build) : undefined;\n // Only a board that builds sorts cards first; elsewhere a working phase is just its own step.\n const triage = build\n ? entries.find(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== build &&\n phase.runner.context !== REVIEW_CONTEXT &&\n phase.runner.context !== buildRole,\n )?.[0]\n : undefined;\n const terminals = entries.filter(([, phase]) => phase.kind === 'terminal').map(([key]) => key);\n const completed = board.sourceClosed?.completed ?? terminals[0];\n const canceled = board.sourceClosed?.canceled ?? terminals.find(key => key !== completed) ?? completed;\n const ref = (phase: string) => Object.freeze({ phase, title: board.phases[phase]!.name });\n const flow = Object.freeze({\n initialPhase: board.initialPhase,\n ...(completed ? { completed: ref(completed) } : {}),\n ...(canceled ? { canceled: ref(canceled) } : {}),\n ...(triage ? { triage } : {}),\n ...(pullRequestReview ? { pullRequestReview } : {}),\n ...(selfReview ? { selfReview } : {}),\n ...(build ? { build } : {}),\n ...(buildRole ? { buildRole } : {}),\n });\n flows.set(board, flow);\n return flow;\n}\n\n/**\n * Where integrations file new items, and where one lands when no intake route takes it: the\n * project's Work board's initial phase, else (a project an app gave only its own boards) the\n * initial phase of its first board in catalog order. Undefined only for a project with no boards.\n */\nexport function intakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): FactoryRuleIntakeTarget | undefined {\n const target = boards.get(DEFAULT_BOARD_ID) ?? boards.values().next().value;\n if (!target) return undefined;\n return Object.freeze({ board: target.id, initialPhase: target.initialPhase });\n}\n\n/** {@link intakeTarget} as a rule context field. */\nexport function withIntakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): { intake?: FactoryRuleIntakeTarget } {\n const intake = intakeTarget(boards);\n return intake ? { intake } : {};\n}\n\n/** {@link boardFlow} of the board a card sits on. */\nexport function cardBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): FactoryRuleBoardFlow {\n return item ? boardFlow(boards.get(boardForWorkItem(item))) : Object.freeze({});\n}\n\n/**\n * Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being\n * triaged. Approval labels hold only such cards.\n */\nexport function awaitsAcceptance(board: InstalledBoard | undefined, stage: string): boolean {\n if (!board) return false;\n return board.phaseKind(stage) === 'resting' || stage === boardFlow(board).triage;\n}\n\n/** Whether `stage` is the phase where the board reviews pull requests. */\nexport function isPullRequestReviewPhase(board: InstalledBoard | undefined, stage: string | undefined): boolean {\n const phase = boardFlow(board).pullRequestReview;\n return phase !== undefined && phase === stage;\n}\n\n/**\n * Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it\n * does not: a pull request's own card is only reviewed, so it enters no other working phase, and\n * the pull request review phase holds only cards that carry a pull request (their own, or one\n * attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and\n * which one fits depends on the card.\n */\nexport function pullRequestCardRejection(\n board: InstalledBoard,\n card: { readonly standalonePullRequest: boolean; readonly hasPullRequest: boolean },\n toStage: string,\n): string | undefined {\n const review = boardFlow(board).pullRequestReview;\n if (!review) return undefined;\n const reviewName = board.phases[review]?.name ?? review;\n if (!card.hasPullRequest && toStage === review) {\n return `${reviewName} holds only cards with a pull request; this work item enters it once a pull request is attached to it.`;\n }\n if (!card.standalonePullRequest || toStage === review || !board.isWorking(toStage)) return undefined;\n const exits = [review, ...Object.keys(board.phases).filter(key => board.isTerminal(key))];\n return `A pull request card is only reviewed on the ${board.name} board; it cannot enter ${toStage}. Move it to ${exits.join(', ')}.`;\n}\n\n/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */\nexport function withBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): { flow?: FactoryRuleBoardFlow } {\n return item ? { flow: cardBoardFlow(boards, item) } : {};\n}\n\ninterface SourcedItem {\n readonly workItem?: { readonly sources?: readonly WorkItemSourceRow[] } | null;\n}\n\n/**\n * A card whose own primary source is a pull or merge request: an outside contributor's\n * PR filed on its own card, or a PR card filed before PRs attached to their issue's card.\n * An issue card with an attached PR is not one; see {@link hasPullRequest}.\n */\nexport function isPullRequestCard(item: { readonly source: string }): boolean {\n return item.source === 'github-pr' || item.source === 'gitlab-pr';\n}\n\n/** Every pull or merge request source on a card, oldest first. */\nexport function pullRequestSources(item: SourcedItem): WorkItemSourceRow[] {\n return (item.workItem?.sources ?? []).filter(source => source.sourceType === 'pull-request');\n}\n\n/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */\nexport function hasPullRequest(item: SourcedItem & { readonly source?: string }): boolean {\n return (\n (item.source !== undefined && isPullRequestCard({ source: item.source })) || pullRequestSources(item).length > 0\n );\n}\n\n/** A source row's external id without the type/workspace scope storage prefixes it with. */\nexport function sourceExternalId(source: Pick<WorkItemSourceRow, 'sourceType' | 'workspaceId' | 'externalId'>): string {\n const prefix = `${source.sourceType}:${source.workspaceId ? `${source.workspaceId}:` : ''}`;\n return source.externalId.startsWith(prefix) ? source.externalId.slice(prefix.length) : source.externalId;\n}\n\n/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */\nexport function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined {\n const metadata = source.metadata ?? {};\n const value = metadata.githubPullRequestNumber ?? metadata.gitlabMergeRequestIid ?? metadata.number;\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\nfunction openSource(source: Pick<WorkItemSourceRow, 'state' | 'metadata'>): boolean {\n const state = source.state ?? source.metadata?.state;\n return state !== 'closed' && state !== 'merged' && source.metadata?.merged !== true;\n}\n\n/**\n * The pull request a PR review pass on this card reviews: the one the card's\n * `openPullRequestNumber` names, else the newest open one, else the newest one.\n */\nexport function reviewedPullRequest(\n item: SourcedItem & { readonly metadata?: Record<string, unknown> | null },\n): WorkItemSourceRow | undefined {\n const sources = pullRequestSources(item);\n const pointer = item.metadata?.openPullRequestNumber;\n return (\n (typeof pointer === 'number' ? sources.find(source => pullRequestSourceNumber(source) === pointer) : undefined) ??\n sources.findLast(openSource) ??\n sources.at(-1)\n );\n}\n\n/** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */\nexport function newestOpenPullRequestNumber(item: SourcedItem, except?: number): number | null {\n const open = pullRequestSources(item).filter(\n source => openSource(source) && pullRequestSourceNumber(source) !== except,\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\ninterface SessionedItem {\n readonly sessions: Readonly<Record<string, { readonly branch?: string | null } | undefined>>;\n}\n\ntype BranchedItem = Pick<Card, 'id' | 'externalSource'> & { readonly workItem: Pick<Card['workItem'], 'metadata'> };\n\n/**\n * Whether a pull request from `headBranch` was opened by the card's own sessions: the head is\n * one of its session branches, or the branch Factory builds the card on (stable even after its\n * session is deleted).\n */\nexport function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean {\n if (!headBranch) return false;\n const buildBranch = workItemBranch({\n id: item.id,\n source: workItemBranchSource(item.externalSource),\n metadata: item.workItem.metadata,\n });\n return buildBranch === headBranch || Object.values(item.sessions).some(session => session?.branch === headBranch);\n}\n\n/** The newest open pull request the card's own sessions opened, other than `except`. */\nexport function newestOwnedOpenPullRequestNumber(\n item: SourcedItem & SessionedItem & BranchedItem,\n except?: number,\n): number | null {\n const open = pullRequestSources(item).filter(\n source =>\n openSource(source) &&\n pullRequestSourceNumber(source) !== except &&\n typeof source.metadata?.headBranch === 'string' &&\n cardOwnsBranch(item, source.metadata.headBranch),\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\n/** The pull or merge request a card's PR review covers, whichever card shape carries it. */\nexport interface ReviewedChangeRequest {\n readonly provider: 'github' | 'gitlab';\n readonly number: number | undefined;\n readonly url: string | null;\n readonly headBranch: string | undefined;\n /** The card is the change request's own card rather than an issue card it is attached to. */\n readonly standalone: boolean;\n}\n\n/**\n * What a PR review on this card reviews: the card's own change request when the card is one,\n * otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.\n */\nexport function reviewedChangeRequest(item: {\n readonly source: string;\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly workItem: {\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly sources?: readonly WorkItemSourceRow[];\n };\n}): ReviewedChangeRequest | undefined {\n if (isPullRequestCard(item)) {\n const metadata = item.workItem.metadata ?? {};\n const gitlab = item.source === 'gitlab-pr';\n const value = (gitlab ? metadata.gitlabMergeRequestIid : metadata.githubPullRequestNumber) ?? metadata.number;\n return {\n provider: gitlab ? 'gitlab' : 'github',\n number: typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined,\n url: item.url ?? item.workItem.url ?? null,\n headBranch: typeof metadata.headBranch === 'string' ? metadata.headBranch : undefined,\n standalone: true,\n };\n }\n const source = reviewedPullRequest(item);\n if (!source) return undefined;\n return {\n provider: source.integrationId === 'gitlab' ? 'gitlab' : 'github',\n number: pullRequestSourceNumber(source),\n url: source.url ?? null,\n headBranch: typeof source.metadata?.headBranch === 'string' ? source.metadata.headBranch : undefined,\n standalone: false,\n };\n}\n\n/**\n * Whether a pass already recorded a verdict on `change`. An issue card can carry\n * several pull requests, so a verdict stamped for another one doesn't count; a\n * verdict with no number (a standalone card, or one stamped before verdicts named\n * their pull request) covers the card.\n */\nexport function hasRecordedVerdict(\n item: Parameters<typeof reviewedChangeRequest>[0],\n change: Pick<ReviewedChangeRequest, 'number'> | undefined = reviewedChangeRequest(item),\n): boolean {\n const covered = item.metadata?.reviewedPullRequestNumber;\n const reviewedAnother = typeof covered === 'number' && change?.number !== undefined && covered !== change.number;\n return typeof item.metadata?.reviewVerdict === 'string' && !reviewedAnother;\n}\n\n/**\n * Whether the rule's card carries a change request its board reviews: the card has one, and its\n * board has a phase that takes pull requests ({@link boardFlow}).\n */\nexport function reviewsPullRequest(context: {\n readonly flow?: Pick<FactoryRuleBoardFlow, 'pullRequestReview'>;\n readonly item?: SourcedItem & { readonly source: string };\n}): boolean {\n return context.flow?.pullRequestReview !== undefined && context.item !== undefined && hasPullRequest(context.item);\n}\n\n/**\n * What the installed board says `phase` means. Returns undefined when the board is not\n * installed or does not declare the phase; callers must fail closed on undefined rather\n * than guess from the phase name.\n */\nexport function resolvePhaseSemantics(\n boards: BoardRegistry,\n boardId: string,\n phase: string,\n): PhaseSemantics | undefined {\n const board = boards.get(boardId);\n const kind = board?.phaseKind(phase);\n if (!board || !kind) return undefined;\n const role = board.roleForPhase(phase);\n return role === undefined ? { kind } : { kind, role };\n}\n\n/**\n * Tool-result rule the installed board declares for `toolName`. Undefined when the board is\n * not installed or declares no rule for the tool; callers must run nothing in that case.\n */\nexport function resolveBoardToolRule(\n boards: BoardRegistry,\n boardId: string,\n toolName: string,\n): BoardToolResultRuleHandler | undefined {\n return boards.get(boardId)?.tools[toolName]?.onResult;\n}\n\n/**\n * Integration event handlers the installed board declares for cards on it, or undefined when the\n * card is unbound, the board is not installed, or it declares none for this integration. Within the\n * map, `null` means the board switched that event off for its cards.\n */\nexport function boardEventHandlers<I extends BoardEventIntegration>(\n boards: Pick<BoardRegistry, 'get'>,\n boardId: string | undefined,\n integration: I,\n): BoardEventRules[I] | undefined {\n return boardId === undefined ? undefined : boards.get(boardId)?.events[integration];\n}\n\n/**\n * Board whose event handlers answer an integration evaluation: the bound card's board, except on\n * the evaluation that files a pull request's own Review card, which is about a card that does\n * not exist yet.\n */\nexport function eventBoardId(context: {\n readonly item?: unknown;\n readonly board?: string;\n readonly pullRequestIntake?: boolean;\n}): string | undefined {\n return context.item && !context.pullRequestIntake ? context.board : undefined;\n}\n\n/** What a card's single current phase means on its installed board, for integration rule contexts. */\nexport function rulePhaseContext(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRulePhaseContext | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || !kind) return undefined;\n const context = board.roleForPhase(stage);\n const phase = board.phases[stage];\n return Object.freeze({\n id: stage,\n kind,\n ...(context === undefined ? {} : { context, role: context }),\n nextPhases: Object.freeze([...(phase?.nextPhases ?? [])]),\n });\n}\n\n/**\n * Whether a persisted card has finished, judged by the board it sits on: the installed board's\n * phase kind first, then, for rows whose board is not installed, the phase kinds of the default\n * board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,\n * so a card is only ever released from ownership on the board's own say-so.\n */\nexport function isTerminalWorkItem(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): boolean {\n const semantics = workItemPhaseSemantics(boards, item);\n if (semantics) return semantics.kind === 'terminal';\n const board = boardForWorkItem(item);\n if (boards.has(board)) return false;\n const seed = board === DEFAULT_BOARD_ID ? workBoard : board === reviewBoard.id ? reviewBoard : undefined;\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n return stage !== undefined && seed !== undefined && seed.isTerminal(stage);\n}\n\n/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */\nexport function workItemPhaseSemantics(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): PhaseSemantics | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n return resolvePhaseSemantics(boards, boardForWorkItem(item), stage);\n}\n\n/**\n * Flow-metric outcomes of each board's phases: the phase the board closes completed sources into\n * (else its first terminal phase) completes a card, other terminal phases cancel it, resting\n * phases queue it, and anything else (working, or a phase the board no longer declares) is in\n * flight.\n */\nexport function boardPhaseOutcomes(boards: Pick<BoardRegistry, 'get'>): MetricsPhaseOutcomes {\n return (item, stage) => {\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || kind === undefined || kind === 'working') return 'pipeline';\n if (kind === 'resting') return 'queued';\n const completed = board.sourceClosed?.completed ?? Object.keys(board.phases).find(key => board.isTerminal(key));\n return stage === completed ? 'completed' : 'canceled';\n };\n}\n\n/**\n * Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed\n * board declares, plus whether the card already sits in a terminal phase. Undefined when the\n * board is not installed or declares no mapping, so closing the source leaves the card alone.\n */\nexport function resolveBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRuleBoardClosure | undefined {\n const board = boards.get(boardForWorkItem(item));\n if (!board?.sourceClosed) return undefined;\n const { completed, canceled } = board.sourceClosed;\n return {\n boardTitle: board.name,\n completed: { phase: completed, title: board.phases[completed]!.name },\n canceled: { phase: canceled, title: board.phases[canceled]!.name },\n itemTerminal: item.stages.some(stage => board.isTerminal(stage)),\n };\n}\n\n/** Rule-context fragment carrying the card's `boardClosure`, empty when the board declares none. */\nexport function withBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { boardClosure?: FactoryRuleBoardClosure } {\n const boardClosure = resolveBoardClosure(boards, item);\n return boardClosure ? { boardClosure } : {};\n}\n\n/** `{ phase }` for spreading into an integration rule context, or `{}` when the phase is unknown. */\nexport function rulePhaseField(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { readonly phase?: FactoryRulePhaseContext } {\n const phase = rulePhaseContext(boards, item);\n return phase ? { phase } : {};\n}\n\n/**\n * The change request a review session on this card may publish checks for: the card's own one,\n * or, for an issue card in its board's pull request review phase, the pull request attached to it.\n */\nexport function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined {\n const source = workItemBranchSource(item.externalSource);\n const own = isPullRequestCard({ source });\n if (!own && (item.stages.length !== 1 || cardBoardFlow(boards, item).pullRequestReview !== item.stages[0])) {\n return undefined;\n }\n const number = reviewedChangeRequest({ ...item, source })?.number;\n if (number !== undefined) return String(number);\n // A GitHub key ends in its number (`github-pr:34`); a GitLab key is encoded, so its digits mean nothing.\n return source === 'github-pr' ? /(\\d+)$/.exec(item.externalSource?.externalId ?? '')?.[1] : undefined;\n}\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAgB,iBAAiB,MAAmC;CAClE,OAAO,KAAK,SAAA;AACd;AAEA,MAAM,wBAAQ,IAAI,QAAsC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,SAAgB,UAAU,OAAyD;CACjF,IAAI,CAAC,OAAO,OAAO,OAAO,OAAO,CAAC,CAAC;CACnC,MAAM,SAAS,MAAM,IAAI,KAAK;CAC9B,IAAI,QAAQ,OAAO;CACnB,MAAM,UAAU,OAAO,QAAQ,MAAM,MAAM;CAC3C,MAAM,UAAU,OAA2B,SACzC,MAAM,SAAS,aACf,MAAM,OAAO,YAAA,aACZ,MAAM,SAAS,CAAC,EAAA,CAAG,MAAK,YAAW,YAAY,IAAI;CACtD,MAAM,oBAAoB,QAAQ,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,MAAM,OAAO,YAAY,SAC7B,CAAC,GAAG,KACJ,KAAA;CACJ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AW;GAAE,OAAO;GAAW,OAAO,MAAM,OAAO,UAAU,CAAE;EAAK;EACpE,UAAU;GAAE,OAAO;GAAU,OAAO,MAAM,OAAO,SAAS,CAAE;EAAK;EACjE,cAAc,KAAK,OAAO,MAAK,UAAS,MAAM,WAAW,KAAK,CAAC;CACjE;AACF;;AAGA,SAAgB,iBACd,QACA,MAC4C;CAC5C,MAAM,eAAe,oBAAoB,QAAQ,IAAI;CACrD,OAAO,eAAe,EAAE,aAAa,IAAI,CAAC;AAC5C;;AAGA,SAAgB,eACd,QACA,MAC8C;CAC9C,MAAM,QAAQ,iBAAiB,QAAQ,IAAI;CAC3C,OAAO,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B;;;;;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 { DEFAULT_BOARD_ID } from './default-board.js';\nimport { REVIEW_CONTEXT } from './define-board.js';\nimport type {\n BoardEventIntegration,\n BoardEventRules,\n BoardPhase,\n BoardPhaseKind,\n BoardToolResultRuleHandler,\n} from './define-board.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { workBoard } from './work.js';\n\nexport interface PhaseSemantics {\n readonly kind: BoardPhaseKind;\n /** Seat that carries a working phase; absent for resting and terminal phases. */\n readonly role?: string;\n}\n\n/**\n * Board that owns a work item. Rows created before boards were persisted carry no `board`;\n * they belong to the default board. (Pull requests used to default to the retired Review board;\n * storage reads those rows as the default board, and keeps cards stored on Review there only in a\n * project that still uses it.)\n */\nexport function boardForWorkItem(item: Pick<Card, 'board'>): string {\n return item.board ?? DEFAULT_BOARD_ID;\n}\n\nconst flows = new WeakMap<object, FactoryRuleBoardFlow>();\n\n/**\n * The phases a board's pull request loop runs through, read from what each phase declares\n * rather than from its key:\n *\n * Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat\n * that records verdicts.\n *\n * - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull\n * requests: a pull request's own card is reviewed there, an attached pull request is reviewed\n * there, verdicts on pull requests are recorded there, and a push or review request re-enters it.\n * - `selfReview`: the first working phase that grants `factory_record_review_verdict` without\n * `factory_review_source`: an independent review of the builder's branch before a pull request.\n * - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs\n * in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that\n * builds nothing has no triage phase.\n * - `build`: the last working phase, in declaration order, that is neither of those and can move\n * into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends\n * requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.\n *\n * A board without a `factory_review_source` phase has no pull request loop.\n */\nexport function boardFlow(board: InstalledBoard | undefined): FactoryRuleBoardFlow {\n if (!board) return Object.freeze({});\n const cached = flows.get(board);\n if (cached) return cached;\n const entries = Object.entries(board.phases) as [string, BoardPhase<string>][];\n const grants = (phase: BoardPhase<string>, tool: string) =>\n phase.kind === 'working' &&\n phase.runner.context === REVIEW_CONTEXT &&\n (phase.tools ?? []).some(granted => granted === tool);\n const pullRequestReview = entries.find(([, phase]) => grants(phase, 'factory_review_source'))?.[0];\n const selfReview = entries.find(\n ([key, phase]) =>\n key !== pullRequestReview &&\n grants(phase, 'factory_record_review_verdict') &&\n !grants(phase, 'factory_review_source'),\n )?.[0];\n const handoff = selfReview ?? pullRequestReview;\n const build = handoff\n ? entries.findLast(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== pullRequestReview &&\n key !== selfReview &&\n board.allowsTransition(key, handoff),\n )?.[0]\n : undefined;\n const buildRole = build ? board.roleForPhase(build) : undefined;\n // Only a board that builds sorts cards first; elsewhere a working phase is just its own step.\n const triage = build\n ? entries.find(\n ([key, phase]) =>\n phase.kind === 'working' &&\n key !== build &&\n phase.runner.context !== REVIEW_CONTEXT &&\n phase.runner.context !== buildRole,\n )?.[0]\n : undefined;\n const terminals = entries.filter(([, phase]) => phase.kind === 'terminal').map(([key]) => key);\n const completed = board.sourceClosed?.completed ?? terminals[0];\n const canceled = board.sourceClosed?.canceled ?? terminals.find(key => key !== completed) ?? completed;\n const ref = (phase: string) => Object.freeze({ phase, title: board.phases[phase]!.name });\n const flow = Object.freeze({\n initialPhase: board.initialPhase,\n ...(completed ? { completed: ref(completed) } : {}),\n ...(canceled ? { canceled: ref(canceled) } : {}),\n ...(triage ? { triage } : {}),\n ...(pullRequestReview ? { pullRequestReview } : {}),\n ...(selfReview ? { selfReview } : {}),\n ...(build ? { build } : {}),\n ...(buildRole ? { buildRole } : {}),\n });\n flows.set(board, flow);\n return flow;\n}\n\n/**\n * Where integrations file new items, and where one lands when no intake route takes it: the\n * project's Work board's initial phase, else (a project an app gave only its own boards) the\n * initial phase of its first board in catalog order. Undefined only for a project with no boards.\n */\nexport function intakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): FactoryRuleIntakeTarget | undefined {\n const target = boards.get(DEFAULT_BOARD_ID) ?? boards.values().next().value;\n if (!target) return undefined;\n return Object.freeze({ board: target.id, initialPhase: target.initialPhase });\n}\n\n/** {@link intakeTarget} as a rule context field. */\nexport function withIntakeTarget(boards: Pick<BoardRegistry, 'get' | 'values'>): { intake?: FactoryRuleIntakeTarget } {\n const intake = intakeTarget(boards);\n return intake ? { intake } : {};\n}\n\n/** {@link boardFlow} of the board a card sits on. */\nexport function cardBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): FactoryRuleBoardFlow {\n return item ? boardFlow(boards.get(boardForWorkItem(item))) : Object.freeze({});\n}\n\n/**\n * Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being\n * triaged. Approval labels hold only such cards.\n */\nexport function awaitsAcceptance(board: InstalledBoard | undefined, stage: string): boolean {\n if (!board) return false;\n return board.phaseKind(stage) === 'resting' || stage === boardFlow(board).triage;\n}\n\n/** Whether `stage` is the phase where the board reviews pull requests. */\nexport function isPullRequestReviewPhase(board: InstalledBoard | undefined, stage: string | undefined): boolean {\n const phase = boardFlow(board).pullRequestReview;\n return phase !== undefined && phase === stage;\n}\n\n/**\n * Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it\n * does not: a pull request's own card is only reviewed, so it enters no other working phase, and\n * the pull request review phase holds only cards that carry a pull request (their own, or one\n * attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and\n * which one fits depends on the card.\n */\nexport function pullRequestCardRejection(\n board: InstalledBoard,\n card: { readonly standalonePullRequest: boolean; readonly hasPullRequest: boolean },\n toStage: string,\n): string | undefined {\n const review = boardFlow(board).pullRequestReview;\n if (!review) return undefined;\n const reviewName = board.phases[review]?.name ?? review;\n if (!card.hasPullRequest && toStage === review) {\n return `${reviewName} holds only cards with a pull request; this work item enters it once a pull request is attached to it.`;\n }\n if (!card.standalonePullRequest || toStage === review || !board.isWorking(toStage)) return undefined;\n const exits = [review, ...Object.keys(board.phases).filter(key => board.isTerminal(key))];\n return `A pull request card is only reviewed on the ${board.name} board; it cannot enter ${toStage}. Move it to ${exits.join(', ')}.`;\n}\n\n/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */\nexport function withBoardFlow(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board'> | undefined,\n): { flow?: FactoryRuleBoardFlow } {\n return item ? { flow: cardBoardFlow(boards, item) } : {};\n}\n\ninterface SourcedItem {\n readonly workItem?: { readonly sources?: readonly WorkItemSourceRow[] } | null;\n}\n\n/**\n * A card whose own primary source is a pull or merge request: an outside contributor's\n * PR filed on its own card, or a PR card filed before PRs attached to their issue's card.\n * An issue card with an attached PR is not one; see {@link hasPullRequest}.\n */\nexport function isPullRequestCard(item: { readonly source: string }): boolean {\n return item.source === 'github-pr' || item.source === 'gitlab-pr';\n}\n\n/** Every pull or merge request source on a card, oldest first. */\nexport function pullRequestSources(item: SourcedItem): WorkItemSourceRow[] {\n return (item.workItem?.sources ?? []).filter(source => source.sourceType === 'pull-request');\n}\n\n/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */\nexport function hasPullRequest(item: SourcedItem & { readonly source?: string }): boolean {\n return (\n (item.source !== undefined && isPullRequestCard({ source: item.source })) || pullRequestSources(item).length > 0\n );\n}\n\n/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */\nexport function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined {\n const metadata = source.metadata ?? {};\n const value = metadata.githubPullRequestNumber ?? metadata.gitlabMergeRequestIid ?? metadata.number;\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n\nfunction openSource(source: Pick<WorkItemSourceRow, 'state' | 'metadata'>): boolean {\n const state = source.state ?? source.metadata?.state;\n return state !== 'closed' && state !== 'merged' && source.metadata?.merged !== true;\n}\n\n/**\n * The pull request a PR review pass on this card reviews: the one the card's\n * `openPullRequestNumber` names, else the newest open one, else the newest one.\n */\nexport function reviewedPullRequest(\n item: SourcedItem & { readonly metadata?: Record<string, unknown> | null },\n): WorkItemSourceRow | undefined {\n const sources = pullRequestSources(item);\n const pointer = item.metadata?.openPullRequestNumber;\n return (\n (typeof pointer === 'number' ? sources.find(source => pullRequestSourceNumber(source) === pointer) : undefined) ??\n sources.findLast(openSource) ??\n sources.at(-1)\n );\n}\n\n/** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */\nexport function newestOpenPullRequestNumber(item: SourcedItem, except?: number): number | null {\n const open = pullRequestSources(item).filter(\n source => openSource(source) && pullRequestSourceNumber(source) !== except,\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\ninterface SessionedItem {\n readonly sessions: Readonly<Record<string, { readonly branch?: string | null } | undefined>>;\n}\n\ntype BranchedItem = Pick<Card, 'id' | 'externalSource'> & { readonly workItem: Pick<Card['workItem'], 'metadata'> };\n\n/**\n * Whether a pull request from `headBranch` was opened by the card's own sessions: the head is\n * one of its session branches, or the branch Factory builds the card on (stable even after its\n * session is deleted).\n */\nexport function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean {\n if (!headBranch) return false;\n const buildBranch = workItemBranch({\n id: item.id,\n source: workItemBranchSource(item.externalSource),\n metadata: item.workItem.metadata,\n });\n return buildBranch === headBranch || Object.values(item.sessions).some(session => session?.branch === headBranch);\n}\n\n/** The newest open pull request the card's own sessions opened, other than `except`. */\nexport function newestOwnedOpenPullRequestNumber(\n item: SourcedItem & SessionedItem & BranchedItem,\n except?: number,\n): number | null {\n const open = pullRequestSources(item).filter(\n source =>\n openSource(source) &&\n pullRequestSourceNumber(source) !== except &&\n typeof source.metadata?.headBranch === 'string' &&\n cardOwnsBranch(item, source.metadata.headBranch),\n );\n return (open.length ? pullRequestSourceNumber(open.at(-1)!) : undefined) ?? null;\n}\n\n/** The pull or merge request a card's PR review covers, whichever card shape carries it. */\nexport interface ReviewedChangeRequest {\n readonly provider: 'github' | 'gitlab';\n readonly number: number | undefined;\n readonly url: string | null;\n readonly headBranch: string | undefined;\n /** The card is the change request's own card rather than an issue card it is attached to. */\n readonly standalone: boolean;\n}\n\n/**\n * What a PR review on this card reviews: the card's own change request when the card is one,\n * otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.\n */\nexport function reviewedChangeRequest(item: {\n readonly source: string;\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly workItem: {\n readonly url?: string | null;\n readonly metadata?: Record<string, unknown> | null;\n readonly sources?: readonly WorkItemSourceRow[];\n };\n}): ReviewedChangeRequest | undefined {\n if (isPullRequestCard(item)) {\n const metadata = item.workItem.metadata ?? {};\n const gitlab = item.source === 'gitlab-pr';\n const value = (gitlab ? metadata.gitlabMergeRequestIid : metadata.githubPullRequestNumber) ?? metadata.number;\n return {\n provider: gitlab ? 'gitlab' : 'github',\n number: typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined,\n url: item.url ?? item.workItem.url ?? null,\n headBranch: typeof metadata.headBranch === 'string' ? metadata.headBranch : undefined,\n standalone: true,\n };\n }\n const source = reviewedPullRequest(item);\n if (!source) return undefined;\n return {\n provider: source.integrationId === 'gitlab' ? 'gitlab' : 'github',\n number: pullRequestSourceNumber(source),\n url: source.url ?? null,\n headBranch: typeof source.metadata?.headBranch === 'string' ? source.metadata.headBranch : undefined,\n standalone: false,\n };\n}\n\n/**\n * Whether a pass already recorded a verdict on `change`. An issue card can carry\n * several pull requests, so a verdict stamped for another one doesn't count; a\n * verdict with no number (a standalone card, or one stamped before verdicts named\n * their pull request) covers the card.\n */\nexport function hasRecordedVerdict(\n item: Parameters<typeof reviewedChangeRequest>[0],\n change: Pick<ReviewedChangeRequest, 'number'> | undefined = reviewedChangeRequest(item),\n): boolean {\n const covered = item.metadata?.reviewedPullRequestNumber;\n const reviewedAnother = typeof covered === 'number' && change?.number !== undefined && covered !== change.number;\n return typeof item.metadata?.reviewVerdict === 'string' && !reviewedAnother;\n}\n\n/**\n * Whether the rule's card carries a change request its board reviews: the card has one, and its\n * board has a phase that takes pull requests ({@link boardFlow}).\n */\nexport function reviewsPullRequest(context: {\n readonly flow?: Pick<FactoryRuleBoardFlow, 'pullRequestReview'>;\n readonly item?: SourcedItem & { readonly source: string };\n}): boolean {\n return context.flow?.pullRequestReview !== undefined && context.item !== undefined && hasPullRequest(context.item);\n}\n\n/**\n * What the installed board says `phase` means. Returns undefined when the board is not\n * installed or does not declare the phase; callers must fail closed on undefined rather\n * than guess from the phase name.\n */\nexport function resolvePhaseSemantics(\n boards: BoardRegistry,\n boardId: string,\n phase: string,\n): PhaseSemantics | undefined {\n const board = boards.get(boardId);\n const kind = board?.phaseKind(phase);\n if (!board || !kind) return undefined;\n const role = board.roleForPhase(phase);\n return role === undefined ? { kind } : { kind, role };\n}\n\n/**\n * Tool-result rule the installed board declares for `toolName`. Undefined when the board is\n * not installed or declares no rule for the tool; callers must run nothing in that case.\n */\nexport function resolveBoardToolRule(\n boards: BoardRegistry,\n boardId: string,\n toolName: string,\n): BoardToolResultRuleHandler | undefined {\n return boards.get(boardId)?.tools[toolName]?.onResult;\n}\n\n/**\n * Integration event handlers the installed board declares for cards on it, or undefined when the\n * card is unbound, the board is not installed, or it declares none for this integration. Within the\n * map, `null` means the board switched that event off for its cards.\n */\nexport function boardEventHandlers<I extends BoardEventIntegration>(\n boards: Pick<BoardRegistry, 'get'>,\n boardId: string | undefined,\n integration: I,\n): BoardEventRules[I] | undefined {\n return boardId === undefined ? undefined : boards.get(boardId)?.events[integration];\n}\n\n/**\n * Board whose event handlers answer an integration evaluation: the bound card's board, except on\n * the evaluation that files a pull request's own Review card, which is about a card that does\n * not exist yet.\n */\nexport function eventBoardId(context: {\n readonly item?: unknown;\n readonly board?: string;\n readonly pullRequestIntake?: boolean;\n}): string | undefined {\n return context.item && !context.pullRequestIntake ? context.board : undefined;\n}\n\n/** What a card's single current phase means on its installed board, for integration rule contexts. */\nexport function rulePhaseContext(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRulePhaseContext | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || !kind) return undefined;\n const context = board.roleForPhase(stage);\n const phase = board.phases[stage];\n return Object.freeze({\n id: stage,\n kind,\n ...(context === undefined ? {} : { context, role: context }),\n nextPhases: Object.freeze([...(phase?.nextPhases ?? [])]),\n });\n}\n\n/**\n * Whether a persisted card has finished, judged by the board it sits on: the installed board's\n * phase kind first, then, for rows whose board is not installed, the phase kinds of the default\n * board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,\n * so a card is only ever released from ownership on the board's own say-so.\n */\nexport function isTerminalWorkItem(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): boolean {\n const semantics = workItemPhaseSemantics(boards, item);\n if (semantics) return semantics.kind === 'terminal';\n const board = boardForWorkItem(item);\n if (boards.has(board)) return false;\n const seed = board === DEFAULT_BOARD_ID ? workBoard : board === reviewBoard.id ? reviewBoard : undefined;\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n return stage !== undefined && seed !== undefined && seed.isTerminal(stage);\n}\n\n/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */\nexport function workItemPhaseSemantics(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): PhaseSemantics | undefined {\n const stage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!stage) return undefined;\n return resolvePhaseSemantics(boards, boardForWorkItem(item), stage);\n}\n\n/**\n * Flow-metric outcomes of each board's phases: the phase the board closes completed sources into\n * (else its first terminal phase) completes a card, other terminal phases cancel it, resting\n * phases queue it, and anything else (working, or a phase the board no longer declares) is in\n * flight.\n */\nexport function boardPhaseOutcomes(boards: Pick<BoardRegistry, 'get'>): MetricsPhaseOutcomes {\n return (item, stage) => {\n const board = boards.get(boardForWorkItem(item));\n const kind = board?.phaseKind(stage);\n if (!board || kind === undefined || kind === 'working') return 'pipeline';\n if (kind === 'resting') return 'queued';\n const completed = board.sourceClosed?.completed ?? Object.keys(board.phases).find(key => board.isTerminal(key));\n return stage === completed ? 'completed' : 'canceled';\n };\n}\n\n/**\n * Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed\n * board declares, plus whether the card already sits in a terminal phase. Undefined when the\n * board is not installed or declares no mapping, so closing the source leaves the card alone.\n */\nexport function resolveBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): FactoryRuleBoardClosure | undefined {\n const board = boards.get(boardForWorkItem(item));\n if (!board?.sourceClosed) return undefined;\n const { completed, canceled } = board.sourceClosed;\n return {\n boardTitle: board.name,\n completed: { phase: completed, title: board.phases[completed]!.name },\n canceled: { phase: canceled, title: board.phases[canceled]!.name },\n itemTerminal: item.stages.some(stage => board.isTerminal(stage)),\n };\n}\n\n/** Rule-context fragment carrying the card's `boardClosure`, empty when the board declares none. */\nexport function withBoardClosure(\n boards: BoardRegistry,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { boardClosure?: FactoryRuleBoardClosure } {\n const boardClosure = resolveBoardClosure(boards, item);\n return boardClosure ? { boardClosure } : {};\n}\n\n/** `{ phase }` for spreading into an integration rule context, or `{}` when the phase is unknown. */\nexport function rulePhaseField(\n boards: Pick<BoardRegistry, 'get'>,\n item: Pick<Card, 'board' | 'externalSource' | 'stages'>,\n): { readonly phase?: FactoryRulePhaseContext } {\n const phase = rulePhaseContext(boards, item);\n return phase ? { phase } : {};\n}\n\n/**\n * The change request a review session on this card may publish checks for: the card's own one,\n * or, for an issue card in its board's pull request review phase, the pull request attached to it.\n */\nexport function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined {\n const source = workItemBranchSource(item.externalSource);\n const own = isPullRequestCard({ source });\n if (!own && (item.stages.length !== 1 || cardBoardFlow(boards, item).pullRequestReview !== item.stages[0])) {\n return undefined;\n }\n const number = reviewedChangeRequest({ ...item, source })?.number;\n if (number !== undefined) return String(number);\n // A GitHub key ends in its number (`github-pr:34`); a GitLab key is encoded, so its digits mean nothing.\n return source === 'github-pr' ? /(\\d+)$/.exec(item.externalSource?.externalId ?? '')?.[1] : undefined;\n}\n\nexport { sourceExternalId } from '../work-items/source-external-id.js';\n"],"mappings":";;;;;;;;;;;;;AAmCA,SAAgB,iBAAiB,MAAmC;CAClE,OAAO,KAAK,SAAA;AACd;AAEA,MAAM,wBAAQ,IAAI,QAAsC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,SAAgB,UAAU,OAAyD;CACjF,IAAI,CAAC,OAAO,OAAO,OAAO,OAAO,CAAC,CAAC;CACnC,MAAM,SAAS,MAAM,IAAI,KAAK;CAC9B,IAAI,QAAQ,OAAO;CACnB,MAAM,UAAU,OAAO,QAAQ,MAAM,MAAM;CAC3C,MAAM,UAAU,OAA2B,SACzC,MAAM,SAAS,aACf,MAAM,OAAO,YAAA,aACZ,MAAM,SAAS,CAAC,EAAA,CAAG,MAAK,YAAW,YAAY,IAAI;CACtD,MAAM,oBAAoB,QAAQ,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,MA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EACjE,cAAc,KAAK,OAAO,MAAK,UAAS,MAAM,WAAW,KAAK,CAAC;CACjE;AACF;;AAGA,SAAgB,iBACd,QACA,MAC4C;CAC5C,MAAM,eAAe,oBAAoB,QAAQ,IAAI;CACrD,OAAO,eAAe,EAAE,aAAa,IAAI,CAAC;AAC5C;;AAGA,SAAgB,eACd,QACA,MAC8C;CAC9C,MAAM,QAAQ,iBAAiB,QAAQ,IAAI;CAC3C,OAAO,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B;;;;;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,4 +1,6 @@
|
|
|
1
1
|
import type { RepositoryAccess, VersionControl } from '../capabilities/version-control.js';
|
|
2
|
+
/** Split repository ids into the groups one token each can name, keeping order and dropping repeats. */
|
|
3
|
+
export declare function groupRepositoryIds(repositoryIds: readonly string[]): string[][];
|
|
2
4
|
/**
|
|
3
5
|
* Access to each of an environment's repositories, minted a group at a time.
|
|
4
6
|
* Asking for one repository asks for its group of up to ten, so a provider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-access.d.ts","sourceRoot":"","sources":["../../src/environment/repository-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAa/G;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,qBAAqB,GAAG,uBAAuB,CAAC,EACrF,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,GAAG,GAAE,MAAM,MAAiB,GAC3B,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"repository-access.d.ts","sourceRoot":"","sources":["../../src/environment/repository-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAa/G,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAK/E;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,qBAAqB,GAAG,uBAAuB,CAAC,EACrF,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,GAAG,GAAE,MAAM,MAAiB,GAC3B,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CA6BrD"}
|