@mastra/factory 0.29.0-alpha.4 → 0.29.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -89
- package/dist/boards/board-events.d.ts +89 -9
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +176 -13
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +14 -1
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/busy-card.d.ts +11 -0
- package/dist/boards/busy-card.d.ts.map +1 -0
- package/dist/boards/busy-card.js +15 -0
- package/dist/boards/busy-card.js.map +1 -0
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +18 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/index.d.ts +2 -1
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +3 -2
- package/dist/boards/intake-dry-run.d.ts +109 -0
- package/dist/boards/intake-dry-run.d.ts.map +1 -0
- package/dist/boards/intake-dry-run.js +158 -0
- package/dist/boards/intake-dry-run.js.map +1 -0
- package/dist/boards/intake-lookup.d.ts +32 -0
- package/dist/boards/intake-lookup.d.ts.map +1 -0
- package/dist/boards/intake-lookup.js +12 -0
- package/dist/boards/intake-lookup.js.map +1 -0
- package/dist/boards/intake-order.d.ts +32 -0
- package/dist/boards/intake-order.d.ts.map +1 -0
- package/dist/boards/intake-order.js +60 -0
- package/dist/boards/intake-order.js.map +1 -0
- package/dist/boards/intake-routing.d.ts +246 -35
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +437 -52
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/reroute.d.ts +7 -3
- package/dist/boards/reroute.d.ts.map +1 -1
- package/dist/boards/reroute.js +21 -4
- package/dist/boards/reroute.js.map +1 -1
- package/dist/boards/semantics.d.ts +8 -28
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +14 -40
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-routes.d.ts +31 -11
- package/dist/boards/work-routes.d.ts.map +1 -1
- package/dist/boards/work-routes.js +104 -20
- package/dist/boards/work-routes.js.map +1 -1
- package/dist/factory.d.ts +37 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +127 -48
- package/dist/factory.js.map +1 -1
- package/dist/integrations/base.d.ts +9 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/dependabot/rules.js +1 -1
- package/dist/integrations/dependabot/rules.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +22 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +23 -5
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/intake-lookup.d.ts +16 -0
- package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/github/intake-lookup.js +76 -0
- package/dist/integrations/github/intake-lookup.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +19 -5
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +21 -6
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-intake.d.ts +15 -0
- package/dist/integrations/github/issue-intake.d.ts.map +1 -0
- package/dist/integrations/github/issue-intake.js +50 -0
- package/dist/integrations/github/issue-intake.js.map +1 -0
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +10 -1
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/review-status-reporter.js +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +14 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +14 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +221 -30
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +30 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +19 -3
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
- package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
- package/dist/integrations/gitlab/intake-lookup.js +85 -0
- package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
- package/dist/integrations/gitlab/integration.d.ts +5 -0
- package/dist/integrations/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/gitlab/integration.js +21 -1
- package/dist/integrations/gitlab/integration.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +20 -0
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +108 -12
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +14 -4
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +12 -2
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +13 -2
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +43 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +82 -7
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
- package/dist/integrations/platform/connect/session-tools.js +28 -10
- package/dist/integrations/platform/connect/session-tools.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +9 -1
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +6 -6
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +22 -3
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +3 -3
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/integrations/pull-request-head.d.ts +1 -1
- package/dist/integrations/pull-request-head.d.ts.map +1 -1
- package/dist/integrations/pull-request-head.js +5 -0
- package/dist/integrations/pull-request-head.js.map +1 -1
- package/dist/integrations/vanta/rules.js +1 -1
- package/dist/integrations/vanta/rules.js.map +1 -1
- package/dist/integrations/vanta/sync.d.ts +9 -0
- package/dist/integrations/vanta/sync.d.ts.map +1 -1
- package/dist/integrations/vanta/sync.js +10 -1
- package/dist/integrations/vanta/sync.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +13 -6
- package/dist/routes/board-snapshot.d.ts.map +1 -1
- package/dist/routes/board-snapshot.js +42 -20
- package/dist/routes/board-snapshot.js.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +17 -2
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +247 -77
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +1294 -7
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +603 -20
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/custom-endpoint-url.d.ts +8 -0
- package/dist/routes/custom-endpoint-url.d.ts.map +1 -0
- package/dist/routes/custom-endpoint-url.js +45 -0
- package/dist/routes/custom-endpoint-url.js.map +1 -0
- package/dist/routes/custom-provider-source.d.ts +24 -8
- package/dist/routes/custom-provider-source.d.ts.map +1 -1
- package/dist/routes/custom-provider-source.js +93 -43
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/intake-check.d.ts +92 -0
- package/dist/routes/intake-check.d.ts.map +1 -0
- package/dist/routes/intake-check.js +322 -0
- package/dist/routes/intake-check.js.map +1 -0
- package/dist/routes/intake-routes.d.ts +10 -2
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +292 -11
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +6 -0
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +20 -0
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts.map +1 -1
- package/dist/routes/mastra-gateway.js +3 -2
- package/dist/routes/mastra-gateway.js.map +1 -1
- package/dist/routes/project-sessions.d.ts +61 -0
- package/dist/routes/project-sessions.d.ts.map +1 -0
- package/dist/routes/project-sessions.js +135 -0
- package/dist/routes/project-sessions.js.map +1 -0
- package/dist/routes/projects.d.ts +6 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +19 -3
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +10 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +13 -16
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/run-queue.d.ts +6 -6
- package/dist/routes/run-queue.d.ts.map +1 -1
- package/dist/routes/run-queue.js +28 -8
- package/dist/routes/run-queue.js.map +1 -1
- package/dist/routes/session-rows.d.ts +30 -0
- package/dist/routes/session-rows.d.ts.map +1 -0
- package/dist/routes/session-rows.js +94 -0
- package/dist/routes/session-rows.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +4 -5
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +8 -87
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +16 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +41 -30
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +4 -4
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/work-item-starters.d.ts +1 -0
- package/dist/routes/work-item-starters.d.ts.map +1 -1
- package/dist/routes/work-item-starters.js +14 -2
- package/dist/routes/work-item-starters.js.map +1 -1
- package/dist/routes/work-items.d.ts +22 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +124 -48
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts +5 -0
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +51 -5
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/dispatch-errors.js +1 -1
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +39 -7
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +363 -123
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +69 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +151 -5
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/review-source-tool.js +1 -1
- package/dist/rules/rule-group.d.ts +18 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +52 -8
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/run-bearing.d.ts +8 -0
- package/dist/rules/run-bearing.d.ts.map +1 -0
- package/dist/rules/run-bearing.js +11 -0
- package/dist/rules/run-bearing.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +2 -3
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +25 -38
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +2 -1
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +16 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +34 -10
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -5
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/update-fold.d.ts +32 -0
- package/dist/rules/update-fold.d.ts.map +1 -0
- package/dist/rules/update-fold.js +60 -0
- package/dist/rules/update-fold.js.map +1 -0
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +54 -6
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/session-retirement.d.ts +6 -0
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +17 -0
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +2 -1
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/live-sessions.d.ts +6 -1
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +4 -0
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js +2 -3
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/run-audit.d.ts +10 -1
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +9 -1
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +26 -2
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +60 -10
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-row-query.d.ts +25 -0
- package/dist/session/session-row-query.d.ts.map +1 -0
- package/dist/session/session-row-query.js +47 -0
- package/dist/session/session-row-query.js.map +1 -0
- package/dist/session/session-row-status.d.ts +16 -0
- package/dist/session/session-row-status.d.ts.map +1 -0
- package/dist/session/session-row-status.js +14 -0
- package/dist/session/session-row-status.js.map +1 -0
- package/dist/session/session-row-view.d.ts +13 -0
- package/dist/session/session-row-view.d.ts.map +1 -0
- package/dist/session/session-row-view.js +118 -0
- package/dist/session/session-row-view.js.map +1 -0
- package/dist/session/session-rows.d.ts +60 -0
- package/dist/session/session-rows.d.ts.map +1 -0
- package/dist/session/session-rows.js +307 -0
- package/dist/session/session-rows.js.map +1 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +1 -0
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/session-unloader.d.ts +101 -0
- package/dist/session/session-unloader.d.ts.map +1 -0
- package/dist/session/session-unloader.js +278 -0
- package/dist/session/session-unloader.js.map +1 -0
- package/dist/session/source-control-tools.d.ts +14 -7
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +10 -2
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +49 -1
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js +118 -15
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts.map +1 -1
- package/dist/session/work-item-state-processor.js +44 -8
- package/dist/session/work-item-state-processor.js.map +1 -1
- package/dist/session-list-changes.d.ts +9 -0
- package/dist/session-list-changes.d.ts.map +1 -0
- package/dist/session-list-changes.js +54 -0
- package/dist/session-list-changes.js.map +1 -0
- package/dist/storage/announced-lists.d.ts +14 -0
- package/dist/storage/announced-lists.d.ts.map +1 -0
- package/dist/storage/announced-lists.js +78 -0
- package/dist/storage/announced-lists.js.map +1 -0
- package/dist/storage/domains/audit/actions.d.ts +2 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +3 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +163 -15
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +440 -48
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts +6 -0
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +95 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/custom-providers/base.d.ts +62 -19
- package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
- package/dist/storage/domains/custom-providers/base.js +131 -100
- package/dist/storage/domains/custom-providers/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +25 -7
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +83 -19
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +19 -10
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +8 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +110 -61
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +8 -5
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +57 -18
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +168 -83
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +3 -2
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +4 -2
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +2 -2
- package/dist/tools/read-tools.d.ts +9 -5
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +61 -54
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/session-tools.d.ts +0 -13
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +128 -341
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +3 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +99 -27
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +4 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +7 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-context-sessions.d.ts +50 -0
- package/dist/work-items/card-context-sessions.d.ts.map +1 -0
- package/dist/work-items/card-context-sessions.js +84 -0
- package/dist/work-items/card-context-sessions.js.map +1 -0
- package/dist/work-items/card-reference.d.ts +21 -0
- package/dist/work-items/card-reference.d.ts.map +1 -0
- package/dist/work-items/card-reference.js +58 -0
- package/dist/work-items/card-reference.js.map +1 -0
- package/dist/work-items/change-requests.d.ts +87 -0
- package/dist/work-items/change-requests.d.ts.map +1 -0
- package/dist/work-items/change-requests.js +134 -0
- package/dist/work-items/change-requests.js.map +1 -0
- package/dist/work-items/create-work-item.d.ts +7 -2
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +44 -13
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/list-related-cards.d.ts.map +1 -1
- package/dist/work-items/list-related-cards.js +1 -1
- package/dist/work-items/list-related-cards.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +1 -0
- package/dist/work-items/providers/github.js.map +1 -1
- package/factory-skills/factory-build/SKILL.md +1 -1
- package/factory-skills/factory-plan/SKILL.md +5 -3
- package/factory-skills/factory-self-review/SKILL.md +2 -0
- package/factory-skills/factory-triage/SKILL.md +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-service.js","names":[],"sources":["../../src/rules/transition-service.ts"],"sourcesContent":["import { DEFAULT_BOARD_ID, REVIEW_CONTEXT } from '../boards/index.js';\nimport type { BoardRegistry, InstalledBoard } from '../boards/index.js';\nimport { autoApprovedExitTool, exitToolSucceeded } from '../boards/phase-automation.js';\nimport { phaseRunDecision } from '../boards/phase-runner.js';\nimport { toBoardSource } from '../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../boards/project-boards.js';\nimport { boardFlow, boardForWorkItem, hasPullRequest, pullRequestCardRejection } from '../boards/semantics.js';\nimport { boardTransitionPolicyResultSchema, immutablePolicySnapshot } from '../boards/transition-policy.js';\nimport type { AuditActorProfileInput, AuditActorType, AuditContext } from '../storage/domains/audit/base.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport { isFactoryPrincipalId } from '../storage/domains/projects/base.js';\nimport { isAgentActor } from '../storage/domains/work-items/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport type {\n FactoryCommitDecision,\n FactoryRuleActor,\n FactoryRuleBoard,\n FactoryRuleCausalEntry,\n FactoryRuleRejectionCode,\n FactoryRuleStage,\n FactoryStageRuleContext,\n FactoryTransitionResult,\n FactoryTransitionResultRejected,\n} from './types.js';\nimport { factoryRuleSourceForWorkItem, workItemSource } from './types.js';\nimport {\n MAX_FACTORY_RULE_CAUSAL_DEPTH,\n assertFactoryDecisionTarget,\n validateFactoryRuleDecision,\n validateFactoryRuleDecisions,\n} from './validation.js';\n\nconst RULE_TIMEOUT_MS = 5_000;\nconst MAX_REJECTION_REASON = 512;\n/** Longest a committed transition waits for terminal resource cleanup. Cleanup\n * reattaches remote sandboxes, so a hung provider call must not leave the\n * already-committed transition request pending; past this bound the cleanup\n * keeps running in the background as pure best-effort. */\nconst TERMINAL_CLEANUP_TIMEOUT_MS = 30_000;\n\nexport interface FactoryTransitionRequest {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n /** Installed board id; the service rejects boards that are not installed. */\n board: string;\n stage: FactoryRuleStage;\n expectedRevision: number;\n actor: FactoryRuleActor;\n actorProfile?: AuditActorProfileInput;\n /** Where a browser request came from; rules and agents carry none. */\n context?: AuditContext;\n ingress: { type: 'human' | 'agent' | 'toolResult' | 'github' | 'rule'; identity: string; transitionId?: string };\n cause: string;\n causalChain?: readonly FactoryRuleCausalEntry[];\n /** Internal materialization path: start the destination phase's runner even when already at that stage. */\n initialEntry?: boolean;\n /** Starts the stage's runner again when the item already holds that stage, to restart work the entry invalidated. */\n reenter?: boolean;\n /** Internal proof that this move consumes an approved `submit_plan` result. */\n planApproved?: true;\n /** Internal: the tool whose successful result this move consumes (a tool-result rule's move). */\n completedTool?: string;\n /**\n * Internal: an intake route moves the card on a status event. A route is admin-authored, so it\n * may name any phase on the card's board regardless of the board's next phases, working ones\n * included. The phase's `autoStart` and the dispatcher's approval check decide whether its run starts.\n */\n eventRoute?: { routeId: string };\n}\n\nexport interface FactoryTransitionServiceOptions {\n configVersion: string;\n storage: WorkItemsStorage;\n /** A fixed registry, or the per-project boards; each transition loads its project's boards. */\n boards?: BoardRegistry | ProjectBoardSource;\n /** Every commit, accepted or rejected, lands here as `stage_moved` / `transition_rejected` under the request's actor. */\n audit?: AuditRecorder;\n timeoutMs?: number;\n /**\n * Called after a transition commits into a phase the board declares\n * terminal — the point where the item's sessions stop receiving runs, so\n * resources they hold (e.g. sandboxes) can be released for reuse. Awaited,\n * but failures are swallowed: releasing resources must never break or roll\n * back the committed transition.\n */\n onTerminalStage?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n stage: FactoryRuleStage;\n revision: number;\n /** The actor that committed this terminal transition. Lets cleanup leave\n * the seat that drove its own transition (an agent tool call) untouched. */\n actor: FactoryRuleActor;\n }) => Promise<void> | void;\n /**\n * Called after a transition commits a stage change, e.g. to tell the item's\n * followers. Not awaited, and failures are logged: a notification must never\n * fail or delay the committed transition.\n */\n onTransitionCommitted?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n fromStage: string | undefined;\n toStage: string;\n }) => Promise<void> | void;\n /**\n * Called after a transition commits out of the last phase that runs in a\n * context: the new phase runs in another context (or none) and is not\n * terminal, e.g. Triage → Planning. The context's session gets no more\n * runs until the card comes back, so its sandbox can stop. Awaited under\n * the same bound as `onTerminalStage`, and failures are swallowed.\n */\n onContextLeft?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n /** The context the card left. */\n context: string;\n /** The context the new phase runs in, if it runs one. */\n toContext: string | undefined;\n revision: number;\n actor: FactoryRuleActor;\n }) => Promise<void> | void;\n /** Upper bound on how long a committed transition waits for\n * `onTerminalStage` or `onContextLeft` before returning (default 30s). The\n * cleanup continues in the background past the bound. */\n terminalCleanupTimeoutMs?: number;\n /**\n * Called after a person moves a Work card from Intake or Triage into Planning or\n * Building, which approves the work. Fire-and-forget: failures are swallowed, the committed transition never\n * depends on it.\n */\n onAccepted?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n item: Card;\n }) => Promise<void> | void;\n}\n\nfunction rejection(\n transitionId: string,\n itemId: string,\n code: FactoryRuleRejectionCode,\n reason: string,\n): FactoryTransitionResult {\n return { status: 'rejected', transitionId, itemId, code, reason: reason.slice(0, MAX_REJECTION_REASON) };\n}\n\nfunction actorId(actor: FactoryRuleActor): string {\n switch (actor.type) {\n case 'human':\n case 'system':\n return actor.id;\n case 'agent':\n return `agent:${actor.bindingId}`;\n case 'github':\n return `github:${actor.login}`;\n case 'gitlab':\n return `gitlab:${actor.username}`;\n }\n}\n\n// The dispatcher executes an agent-approved decision as a human actor so its consent carries; the trail still names the agent.\nexport function auditActorOf(actor: FactoryRuleActor): { actorId: string; actorType: AuditActorType } {\n const id = actorId(actor);\n switch (actor.type) {\n case 'github':\n case 'gitlab':\n return { actorId: id, actorType: 'human' };\n case 'human':\n return { actorId: id, actorType: isAgentActor(id) ? 'agent' : isFactoryPrincipalId(id) ? 'system' : 'human' };\n default:\n return { actorId: id, actorType: actor.type };\n }\n}\n\nfunction isStale(result: FactoryTransitionResult): result is FactoryTransitionResultRejected {\n return result.status === 'rejected' && result.code === 'stale';\n}\n\n/** Tell the caller where the card is now, so a model doesn't read \"stale\" as \"already moved\". */\nfunction staleRejection(result: FactoryTransitionResultRejected, current: Card): FactoryTransitionResult {\n const stage = currentStage(current.stages) ?? current.stages.join(', ');\n return rejection(\n result.transitionId,\n result.itemId,\n 'stale',\n `The card changed (now revision ${current.revision}, in ${stage}). Retry with expectedRevision ${current.revision} if the move still applies.`,\n );\n}\n\nexport function currentStage(stages: readonly string[]): FactoryRuleStage | undefined {\n return stages.length === 1 ? stages[0] : undefined;\n}\n\ninterface TransitionConsentOptions {\n autonomy?: 'arm' | 'disarm';\n consentedBy?: string;\n /** A person moved a card into its board's build seat from before it (see {@link acceptsWork}): that move approves the work. */\n accepted?: boolean;\n}\n\n/**\n * Whether moving a card from `from` to `to` hands it to the board's builder for the first time: `to`\n * runs in the seat of the board's build phase ({@link boardFlow}), and `from` is a resting phase or a\n * working phase of another seat that is no review (Work: Intake or Triage into Planning or Building).\n */\nfunction acceptsWork(board: InstalledBoard, from: string, to: string): boolean {\n const buildRole = boardFlow(board).buildRole;\n if (!buildRole || board.roleForPhase(to) !== buildRole) return false;\n const fromPhase = board.phases[from];\n if (!fromPhase || fromPhase.kind === 'terminal') return false;\n if (fromPhase.kind === 'resting') return true;\n const fromRole = fromPhase.runner.context;\n return fromRole !== buildRole && fromRole !== REVIEW_CONTEXT;\n}\n\n// Entering a resting lane disarms whoever rests it; only a person's move into a working lane arms.\nfunction transitionConsent(working: boolean, humanMove: boolean): 'arm' | 'disarm' | undefined {\n if (!working) return 'disarm';\n return humanMove ? 'arm' : undefined;\n}\n\n// An event arriving as data (GitHub, sweeps) never pre-approves the runs its transition queues.\nfunction bearsConsent(actor: FactoryRuleActor): boolean {\n return actor.type === 'human' || actor.type === 'agent';\n}\n\n// Rides the transition's own revision-checked commit, so a stale or rejected commit flips nothing.\nfunction consentEffect(\n request: FactoryTransitionRequest,\n working: boolean,\n humanMove: boolean,\n): TransitionConsentOptions {\n // A provider event (a reopen, a close) is not a person's say-so: whatever a person armed before\n // no longer stands once a route moves the card.\n if (request.eventRoute) return { autonomy: 'disarm' };\n const autonomy = transitionConsent(working, humanMove);\n return bearsConsent(request.actor) ? { autonomy, consentedBy: actorId(request.actor) } : { autonomy };\n}\n\ntype RunStartDecision = Extract<FactoryCommitDecision, { type: 'invokeSkill' | 'sendMessage' }>;\n\nfunction startsRun(decision: FactoryCommitDecision): decision is RunStartDecision {\n return decision.type === 'invokeSkill' || (decision.type === 'sendMessage' && decision.prepareBinding === true);\n}\n\n// Answering a recorded run start, or the role's own mid-run agent, with a run would start a second one.\n// A run that starts after its own agent's move is queued onto that agent's run instead.\nfunction runAlreadyUnderway(request: FactoryTransitionRequest, decision: RunStartDecision): boolean {\n if (request.cause === 'run_start') return true;\n if (decision.type === 'invokeSkill' && decision.startsAfterOwnMove === true) return false;\n return request.actor.type === 'agent' && request.actor.role === decision.role;\n}\n\nfunction stageTransitionMessage(fromStage: FactoryRuleStage, toStage: FactoryRuleStage): string {\n return `This work was moved from the ${fromStage} stage to the ${toStage} stage.`;\n}\n\nfunction isHumanTransition(request: FactoryTransitionRequest): boolean {\n return request.actor.type === 'human' && request.ingress.type === 'human';\n}\n\nfunction ruleFailure(error: unknown): { code: FactoryRuleRejectionCode; reason: string } {\n return {\n code: 'rule_error',\n reason: error instanceof Error ? `Factory rule failed: ${error.message}` : 'Factory rule failed.',\n };\n}\n\nasync function withRuleTimeout<T>(operation: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('FACTORY_RULE_TIMEOUT')), timeoutMs);\n });\n try {\n return await Promise.race([operation, timeout]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nexport class FactoryTransitionService {\n readonly #configVersion: string;\n readonly #boards: ProjectBoardSource;\n readonly #storage: WorkItemsStorage;\n readonly #timeoutMs: number;\n readonly #onTerminalStage: FactoryTransitionServiceOptions['onTerminalStage'];\n readonly #onContextLeft: FactoryTransitionServiceOptions['onContextLeft'];\n readonly #terminalCleanupTimeoutMs: number;\n readonly #onAccepted: FactoryTransitionServiceOptions['onAccepted'];\n readonly #onTransitionCommitted: FactoryTransitionServiceOptions['onTransitionCommitted'];\n readonly #audit: AuditRecorder | undefined;\n\n constructor(options: FactoryTransitionServiceOptions) {\n this.#configVersion = options.configVersion;\n this.#boards = toBoardSource(options.boards);\n this.#storage = options.storage;\n this.#audit = options.audit;\n this.#timeoutMs = options.timeoutMs ?? RULE_TIMEOUT_MS;\n this.#onTerminalStage = options.onTerminalStage;\n this.#onContextLeft = options.onContextLeft;\n this.#onAccepted = options.onAccepted;\n this.#onTransitionCommitted = options.onTransitionCommitted;\n this.#terminalCleanupTimeoutMs = options.terminalCleanupTimeoutMs ?? TERMINAL_CLEANUP_TIMEOUT_MS;\n }\n\n get configVersion(): string {\n return this.#configVersion;\n }\n\n async transition(request: FactoryTransitionRequest): Promise<FactoryTransitionResult> {\n const replay = await this.#storage.getTransitionResultByIngress(\n request.orgId,\n request.factoryProjectId,\n request.ingress.identity,\n );\n if (replay) return replay as unknown as FactoryTransitionResult;\n\n const transitionId = request.ingress.transitionId ?? globalThis.crypto.randomUUID();\n const item = await this.#storage.get({ orgId: request.orgId, id: request.workItemId });\n if (!item) {\n const rejection = await this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'Work item not found.',\n );\n await this.#recordTransition(request, undefined, rejection);\n return rejection;\n }\n let result = await this.#evaluateAndCommit(request, transitionId, item);\n if (isStale(result)) {\n const current = await this.#storage.get({ orgId: request.orgId, id: request.workItemId });\n if (current) result = staleRejection(result, current);\n }\n await this.#recordTransition(request, item, result);\n this.#notifyCommitted(request, item, result);\n return result;\n }\n\n #notifyCommitted(request: FactoryTransitionRequest, item: Card, result: FactoryTransitionResult): void {\n const onTransitionCommitted = this.#onTransitionCommitted;\n if (!onTransitionCommitted || result.status !== 'accepted') return;\n // Board-neutral: `currentStage` only knows the built-in rule stages.\n const fromStage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (result.stage === fromStage) return;\n // Inside the chain so a synchronous throw is isolated the same way an async rejection is.\n void Promise.resolve()\n .then(() =>\n onTransitionCommitted({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: item.id,\n fromStage,\n toStage: result.stage,\n }),\n )\n .catch(error => {\n console.warn(`[factory] stage notification failed for work item ${item.id}:`, error);\n });\n }\n\n /** A rejection can outlive its work item: the row still names the id the caller asked for. */\n async #recordTransition(\n request: FactoryTransitionRequest,\n item: Card | undefined,\n result: FactoryTransitionResult,\n ): Promise<void> {\n if (!this.#audit) return;\n // Board-neutral, like the stage notification: `currentStage` only knows the\n // built-in rule stages and would drop custom-board phases.\n const from = item && item.stages.length === 1 ? item.stages[0] : undefined;\n if (result.status === 'accepted' && result.stage === from && !request.reenter) return;\n const outcome =\n result.status === 'accepted'\n ? { action: 'factory.work_item.stage_moved' as const, to: result.stage, revision: result.revision }\n : {\n action: 'factory.work_item.transition_rejected' as const,\n to: request.stage,\n code: result.code,\n reason: result.reason,\n };\n const { action, ...detail } = outcome;\n await this.#audit\n .record({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n ...auditActorOf(request.actor),\n actorProfile: request.actorProfile,\n ...(request.context ? { context: request.context } : {}),\n action,\n idempotencyKey: result.transitionId,\n targets: [{ type: 'work_item', id: item?.id ?? request.workItemId, ...(item ? { name: item.title } : {}) }],\n metadata: {\n transitionId: result.transitionId,\n ingressType: request.ingress.type,\n cause: request.cause,\n configVersion: this.#configVersion,\n ...(from ? { from } : {}),\n ...(request.reenter ? { reenter: true } : {}),\n ...detail,\n },\n })\n .catch(error => {\n console.warn(`[factory] audit failed for transition ${result.transitionId}:`, error);\n });\n }\n\n async #evaluateAndCommit(\n request: FactoryTransitionRequest,\n transitionId: string,\n item: Card,\n ): Promise<FactoryTransitionResult> {\n const boards = await this.#boards.load(request);\n if (request.causalChain && request.causalChain.length > MAX_FACTORY_RULE_CAUSAL_DEPTH) {\n return this.#commitRejection(\n request,\n transitionId,\n 'causal_depth_exceeded',\n 'Factory rule causal depth exceeded.',\n );\n }\n const itemSource = workItemSource(item.externalSource);\n const source = factoryRuleSourceForWorkItem(itemSource);\n const isPullRequest = source === 'pullRequest' || source === 'gitlabPullRequest';\n // Rows filed before boards were persisted belong to the default board.\n if (item.board === null && !boards.has(DEFAULT_BOARD_ID)) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'This legacy work item has no assigned board. Assign an installed board and phase through the work-item PATCH endpoint before transitioning it.',\n );\n }\n const itemBoard = boardForWorkItem(item);\n if (request.board !== itemBoard) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `The work item belongs to board \"${itemBoard}\", not \"${request.board}\".`,\n );\n }\n const board = boards.get(request.board);\n if (!board) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `Board \"${request.board}\" is not installed.`,\n );\n }\n const fromStage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!fromStage || !Object.prototype.hasOwnProperty.call(board.phases, fromStage)) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'The work item does not have one canonical phase on the requested board.',\n );\n }\n // The board's own reason comes first: its phase graph alone only says the move is not\n // declared, which leaves an agent moving an issue card to PR review guessing why.\n const cardShapeRejection = pullRequestCardRejection(\n board,\n {\n standalonePullRequest: isPullRequest,\n hasPullRequest: hasPullRequest({ workItem: item.workItem, source: itemSource }),\n },\n request.stage,\n );\n if (cardShapeRejection) {\n return this.#commitRejection(request, transitionId, 'invalid_transition', cardShapeRejection);\n }\n if (\n !Object.prototype.hasOwnProperty.call(board.phases, request.stage) ||\n (!request.eventRoute && !board.allowsTransition(fromStage, request.stage))\n ) {\n const nextStages = [...new Set((board.transitions[fromStage] ?? []).map(transition => transition.to))];\n const nextStagesReason =\n nextStages.length > 0\n ? `Next stages declared from ${fromStage}: ${nextStages.join(', ')}.`\n : `No next stage is declared from ${fromStage}.`;\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `The ${board.name} board does not allow moving from ${fromStage} to ${request.stage}. ${nextStagesReason}`,\n );\n }\n\n // The coordinator's own self-move at run start would otherwise inject a second run's kickoff.\n const humanMove = request.actor.type === 'human' && fromStage !== request.stage && request.cause !== 'run_start';\n // The board, not the phase name, says whether a seat is engaged on either side of this move.\n const entersWorking = board.isWorking(request.stage);\n const seatRole = board.roleForPhase(request.stage);\n\n const contextBase = {\n tenant: { orgId: request.orgId, projectId: request.factoryProjectId },\n actor: request.actor,\n ingress: { type: request.ingress.type, id: request.ingress.identity },\n cause: request.cause,\n causalChain: request.causalChain ?? [],\n configVersion: this.#configVersion,\n item: {\n id: item.id,\n source: itemSource,\n sourceKey: item.externalSource\n ? `${item.externalSource.integrationId}:${item.externalSource.type}:${item.externalSource.externalId}`\n : null,\n parentWorkItemId: item.parentWorkItemId,\n title: item.title,\n url: item.externalSource?.url ?? null,\n stages: [...item.stages],\n workItem: item.workItem,\n acceptedAt: item.acceptedAt,\n metadata: item.metadata,\n },\n board: request.board,\n itemRevision: item.revision,\n source,\n fromStage,\n toStage: request.stage,\n } satisfies Omit<FactoryStageRuleContext, 'stage'>;\n\n let evaluation:\n | { outcome: 'accepted'; decisions: Record<string, unknown>[]; intents: TransitionConsentOptions }\n | { outcome: 'rejected'; code: string; reason: string };\n try {\n evaluation = await withRuleTimeout(\n (async () => {\n // Plans are approved without a person only where the card's phase auto-approves submit_plan.\n const plansAutoApproved = autoApprovedExitTool(boards, item) === 'submit_plan';\n // A phase with an exit tool holds the card until the tool succeeds (for submit_plan, with\n // an approved plan; autoApprove only decides whether it approves itself). Then the agent,\n // or the board's own rule for the tool, moves the card. A person can move it any time.\n const fromPhase = board.phases[fromStage];\n const exitTool = fromPhase?.kind === 'working' ? fromPhase.exitTool : undefined;\n if (\n request.actor.type !== 'human' &&\n // A start lands the card where its run already is; it is not the agent leaving a phase.\n request.cause !== 'run_start' &&\n !request.eventRoute &&\n exitTool &&\n fromStage !== request.stage &&\n entersWorking &&\n !(exitTool.id === 'submit_plan' ? request.planApproved === true : request.completedTool === exitTool.id) &&\n !exitToolSucceeded(item, fromStage, exitTool.id)\n ) {\n return {\n outcome: 'rejected' as const,\n code: 'approval_required',\n reason:\n exitTool.id === 'submit_plan'\n ? `${fromPhase!.name} ends when submit_plan comes back with an approved plan; until then the card stays here. Call submit_plan and wait for a person to approve the plan (or for it to be approved automatically), then move the card into ${board.phases[request.stage]?.name ?? request.stage} with factory_transition_work_item.`\n : `${fromPhase!.name} ends when ${exitTool.id} succeeds; until then the card stays here. A person can also move it from the Factory board or a chat they are signed in to.`,\n };\n }\n const policy = boardTransitionPolicyResultSchema.parse(\n await board.transitionPolicy?.(\n immutablePolicySnapshot({\n ...contextBase,\n item: { ...contextBase.item, triageType: item.triageType },\n initialEntry: request.initialEntry ?? false,\n reenter: request.reenter ?? false,\n isHumanTransition: isHumanTransition(request),\n plansAutoApproved,\n planApproved: request.planApproved === true,\n requestedTriageType: undefined,\n }),\n ),\n );\n if (policy?.type === 'reject') {\n return { outcome: 'rejected' as const, code: policy.code, reason: policy.reason };\n }\n const run = phaseRunDecision(board, request.stage, contextBase, {\n initialEntry: request.initialEntry,\n reenter: request.reenter,\n });\n const validated = validateFactoryRuleDecisions(run ? [run] : [], contextBase.causalChain.length).filter(\n decision => {\n assertFactoryDecisionTarget(decision, boards, itemBoard);\n return !(startsRun(decision) && runAlreadyUnderway(request, decision));\n },\n );\n if (humanMove) {\n const message = stageTransitionMessage(fromStage, request.stage);\n const skill = validated.find(decision => decision.type === 'invokeSkill');\n if (skill) {\n skill.precedingMessage = message;\n } else {\n validated.unshift({\n type: 'sendMessage',\n idempotencyKey: `factory-stage:${transitionId}`,\n message,\n priority: 'urgent',\n idleBehavior: 'wake',\n // Parking a card says stop: no seat is right by construction, so\n // the notice goes to whichever session is live — or nobody.\n ...(entersWorking && seatRole !== undefined ? { role: seatRole, prepareBinding: true } : {}),\n });\n }\n }\n return {\n outcome: 'accepted' as const,\n intents: {\n accepted: isHumanTransition(request) && acceptsWork(board, fromStage, request.stage),\n },\n decisions: validateFactoryRuleDecisions(validated) as unknown as Record<string, unknown>[],\n };\n })(),\n this.#timeoutMs,\n );\n } catch (error) {\n const failed =\n error instanceof Error && error.message === 'FACTORY_RULE_TIMEOUT'\n ? { code: 'timeout' as const, reason: 'Factory rule evaluation timed out.' }\n : ruleFailure(error);\n evaluation = { outcome: 'rejected', ...failed };\n }\n return this.#commit(\n request,\n transitionId,\n evaluation,\n evaluation.outcome === 'accepted'\n ? { ...consentEffect(request, entersWorking, humanMove), ...evaluation.intents }\n : {},\n boards,\n fromStage,\n );\n }\n\n async #commitRejection(\n request: FactoryTransitionRequest,\n transitionId: string,\n code: FactoryRuleRejectionCode,\n reason: string,\n ): Promise<FactoryTransitionResult> {\n return this.#commit(\n request,\n transitionId,\n { outcome: 'rejected', code, reason: reason.slice(0, MAX_REJECTION_REASON) },\n {},\n undefined,\n );\n }\n\n async #commit(\n request: FactoryTransitionRequest,\n transitionId: string,\n evaluation:\n | { outcome: 'accepted'; decisions: Record<string, unknown>[] }\n | { outcome: 'rejected'; code: string; reason: string },\n options: TransitionConsentOptions,\n // The registry the move was evaluated against; rejected moves never release resources.\n boards: BoardRegistry | undefined,\n fromStage?: string,\n ): Promise<FactoryTransitionResult> {\n const committed = await this.#storage.commitTransition({\n autonomy: options.autonomy,\n consentedBy: options.consentedBy,\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n expectedRevision: request.expectedRevision,\n destinationStage: request.stage,\n actorId: actorId(request.actor),\n ingress: { identity: request.ingress.identity, transitionId },\n causalChain: [...(request.causalChain ?? [])],\n evaluation,\n });\n if (committed.status === 'missing') {\n return rejection(transitionId, request.workItemId, 'invalid_transition', 'Work item not found.');\n }\n const result = committed.result as unknown as FactoryTransitionResult;\n if (\n this.#onAccepted &&\n options.accepted &&\n committed.status === 'committed' &&\n result.status === 'accepted' &&\n committed.item\n ) {\n const item = committed.item;\n const onAccepted = this.#onAccepted;\n // Invoke inside the chain so a synchronous throw is isolated the same way an async rejection is.\n void Promise.resolve()\n .then(() =>\n onAccepted({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n item,\n }),\n )\n .catch(error => {\n console.warn(`[factory] acceptance hook failed for work item ${request.workItemId}:`, error);\n });\n }\n // Only an installed board's declaration releases resources; an unknown board or phase never does.\n const board = result.status === 'accepted' ? boards?.get(request.board) : undefined;\n if (board && result.status === 'accepted') {\n const hooks = {\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n revision: result.revision,\n actor: request.actor,\n };\n if (board.isTerminal(result.stage)) {\n const onTerminalStage = this.#onTerminalStage;\n if (onTerminalStage) await this.#bounded(() => onTerminalStage({ ...hooks, stage: result.stage }));\n } else if (fromStage !== undefined && this.#onContextLeft) {\n const context = board.roleForPhase(fromStage);\n const toContext = board.roleForPhase(result.stage);\n const onContextLeft = this.#onContextLeft;\n if (context !== undefined && context !== toContext) {\n await this.#bounded(() => onContextLeft({ ...hooks, context, toContext }));\n }\n }\n }\n return result;\n }\n\n /** Run a resource-release hook, waiting at most the cleanup bound; it never fails the committed transition. */\n async #bounded(release: () => Promise<void> | void): Promise<void> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const cleanup = Promise.resolve().then(release);\n // A late rejection after the timeout wins the race must not surface\n // as an unhandled rejection.\n cleanup.catch(() => {});\n await Promise.race([\n cleanup,\n new Promise<void>(resolve => {\n timer = setTimeout(resolve, this.#terminalCleanupTimeoutMs);\n }),\n ]);\n } catch {\n // Resource release is best-effort — never fail a committed transition.\n } finally {\n clearTimeout(timer);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;;;;;AAK7B,MAAM,8BAA8B;AAyGpC,SAAS,UACP,cACA,QACA,MACA,QACyB;CACzB,OAAO;EAAE,QAAQ;EAAY;EAAc;EAAQ;EAAM,QAAQ,OAAO,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AAa,SAAS;IAC5C,MAAM,YAAY,MAAM,aAAa,OAAO,KAAK;IACjD,MAAM,gBAAgB,KAAK;IAC3B,IAAI,YAAY,KAAA,KAAa,YAAY,WACvC,MAAM,KAAK,eAAe,cAAc;KAAE,GAAG;KAAO;KAAS;IAAU,CAAC,CAAC;GAE7E;EACF;EACA,OAAO;CACT;;CAGA,MAAM,SAAS,SAAoD;EACjE,IAAI;EACJ,IAAI;GACF,MAAM,UAAU,QAAQ,QAAQ,CAAC,CAAC,KAAK,OAAO;GAG9C,QAAQ,YAAY,CAAC,CAAC;GACtB,MAAM,QAAQ,KAAK,CACjB,SACA,IAAI,SAAc,YAAW;IAC3B,QAAQ,WAAW,SAAS,KAAK,yBAAyB;GAC5D,CAAC,CACH,CAAC;EACH,QAAQ,CAER,UAAU;GACR,aAAa,KAAK;EACpB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"transition-service.js","names":[],"sources":["../../src/rules/transition-service.ts"],"sourcesContent":["import { BUSY_CARD_MOVE_REFUSAL, phaseMayStartRun } from '../boards/busy-card.js';\nimport { DEFAULT_BOARD_ID, REVIEW_CONTEXT } from '../boards/index.js';\nimport type { BoardRegistry, InstalledBoard } from '../boards/index.js';\nimport { autoApprovedExitTool, exitToolSucceeded } from '../boards/phase-automation.js';\nimport { phaseRunDecision } from '../boards/phase-runner.js';\nimport { toBoardSource } from '../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../boards/project-boards.js';\nimport { boardFlow, boardForWorkItem, hasPullRequest, pullRequestCardRejection } from '../boards/semantics.js';\nimport { boardTransitionPolicyResultSchema, immutablePolicySnapshot } from '../boards/transition-policy.js';\nimport type { AuditActorProfileInput, AuditActorType, AuditContext } from '../storage/domains/audit/base.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport { isFactoryPrincipalId } from '../storage/domains/projects/base.js';\nimport { isAgentActor } from '../storage/domains/work-items/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { isRunBearingDecision } from './run-bearing.js';\nimport type {\n FactoryCommitDecision,\n FactoryRuleActor,\n FactoryRuleBoard,\n FactoryRuleCausalEntry,\n FactoryRuleRejectionCode,\n FactoryRuleStage,\n FactoryStageRuleContext,\n FactoryTransitionResult,\n FactoryTransitionResultRejected,\n} from './types.js';\nimport { factoryRuleSourceForWorkItem, workItemSource } from './types.js';\nimport {\n MAX_FACTORY_RULE_CAUSAL_DEPTH,\n assertFactoryDecisionTarget,\n validateFactoryRuleDecision,\n validateFactoryRuleDecisions,\n} from './validation.js';\n\nconst RULE_TIMEOUT_MS = 5_000;\nconst MAX_REJECTION_REASON = 512;\n/** Longest a committed transition waits for terminal resource cleanup. Cleanup\n * reattaches remote sandboxes, so a hung provider call must not leave the\n * already-committed transition request pending; past this bound the cleanup\n * keeps running in the background as pure best-effort. */\nconst TERMINAL_CLEANUP_TIMEOUT_MS = 30_000;\n\nexport interface FactoryTransitionRequest {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n /** Installed board id; the service rejects boards that are not installed. */\n board: string;\n stage: FactoryRuleStage;\n expectedRevision: number;\n actor: FactoryRuleActor;\n actorProfile?: AuditActorProfileInput;\n /** Where a browser request came from; rules and agents carry none. */\n context?: AuditContext;\n ingress: { type: 'human' | 'agent' | 'toolResult' | 'github' | 'rule'; identity: string; transitionId?: string };\n cause: string;\n causalChain?: readonly FactoryRuleCausalEntry[];\n /** Internal materialization path: start the destination phase's runner even when already at that stage. */\n initialEntry?: boolean;\n /** Starts the stage's runner again when the item already holds that stage, to restart work the entry invalidated. */\n reenter?: boolean;\n /** Internal proof that this move consumes an approved `submit_plan` result. */\n planApproved?: true;\n /** Internal: the tool whose successful result this move consumes (a tool-result rule's move). */\n completedTool?: string;\n /**\n * Internal: an intake route moves the card on a status event. A route is admin-authored, so it\n * may name any phase on the card's board regardless of the board's next phases, working ones\n * included. The phase's `autoStart` and the dispatcher's approval check decide whether its run starts.\n */\n eventRoute?: { routeId: string };\n /**\n * Internal, with `eventRoute` only: the installed board the route moves the card to, at `stage`.\n * `board` stays the card's current board. The target board's next phases don't restrict the\n * move; its phase, card shape and policy checks still apply, and its phase's runner starts.\n */\n toBoard?: string;\n}\n\nexport interface FactoryTransitionServiceOptions {\n configVersion: string;\n storage: WorkItemsStorage;\n /** A fixed registry, or the per-project boards; each transition loads its project's boards. */\n boards?: BoardRegistry | ProjectBoardSource;\n /** Every commit, accepted or rejected, lands here as `stage_moved` / `transition_rejected` under the request's actor. */\n audit?: AuditRecorder;\n timeoutMs?: number;\n /**\n * Called after a transition commits into a phase the board declares\n * terminal — the point where the item's sessions stop receiving runs, so\n * resources they hold (e.g. sandboxes) can be released for reuse. Awaited,\n * but failures are swallowed: releasing resources must never break or roll\n * back the committed transition.\n */\n onTerminalStage?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n stage: FactoryRuleStage;\n revision: number;\n /** The actor that committed this terminal transition. Lets cleanup leave\n * the seat that drove its own transition (an agent tool call) untouched. */\n actor: FactoryRuleActor;\n }) => Promise<void> | void;\n /**\n * Called after a transition commits a stage change, e.g. to tell the item's\n * followers. Not awaited, and failures are logged: a notification must never\n * fail or delay the committed transition.\n */\n onTransitionCommitted?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n fromStage: string | undefined;\n toStage: string;\n }) => Promise<void> | void;\n /**\n * Called after a transition commits out of the last phase that runs in a\n * context: the new phase runs in another context (or none) and is not\n * terminal, e.g. Triage → Planning. The context's session gets no more\n * runs until the card comes back, so its sandbox can stop. Awaited under\n * the same bound as `onTerminalStage`, and failures are swallowed.\n */\n onContextLeft?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n /** The context the card left. */\n context: string;\n /** The context the new phase runs in, if it runs one. */\n toContext: string | undefined;\n revision: number;\n actor: FactoryRuleActor;\n }) => Promise<void> | void;\n /** Upper bound on how long a committed transition waits for\n * `onTerminalStage` or `onContextLeft` before returning (default 30s). The\n * cleanup continues in the background past the bound. */\n terminalCleanupTimeoutMs?: number;\n /**\n * Whether a run is in flight on the card's sessions. With a run queued for the card, it makes the\n * card busy, and a person's move into a phase that may start a run is refused while it is.\n * Without it only a queued run counts.\n */\n runInFlight?: (card: { orgId: string; factoryProjectId: string; workItemId: string }) => Promise<boolean>;\n /**\n * Called after a person moves a Work card from Intake or Triage into Planning or\n * Building, which approves the work. Fire-and-forget: failures are swallowed, the committed transition never\n * depends on it.\n */\n onAccepted?: (args: {\n orgId: string;\n factoryProjectId: string;\n workItemId: string;\n item: Card;\n }) => Promise<void> | void;\n}\n\nfunction rejection(\n transitionId: string,\n itemId: string,\n code: FactoryRuleRejectionCode,\n reason: string,\n): FactoryTransitionResult {\n return { status: 'rejected', transitionId, itemId, code, reason: reason.slice(0, MAX_REJECTION_REASON) };\n}\n\nfunction actorId(actor: FactoryRuleActor): string {\n switch (actor.type) {\n case 'human':\n case 'system':\n return actor.id;\n case 'agent':\n return `agent:${actor.bindingId}`;\n case 'github':\n return `github:${actor.login}`;\n case 'gitlab':\n return `gitlab:${actor.username}`;\n }\n}\n\n// The dispatcher executes an agent-approved decision as a human actor so its consent carries; the trail still names the agent.\nexport function auditActorOf(actor: FactoryRuleActor): { actorId: string; actorType: AuditActorType } {\n const id = actorId(actor);\n switch (actor.type) {\n case 'github':\n case 'gitlab':\n return { actorId: id, actorType: 'human' };\n case 'human':\n return { actorId: id, actorType: isAgentActor(id) ? 'agent' : isFactoryPrincipalId(id) ? 'system' : 'human' };\n default:\n return { actorId: id, actorType: actor.type };\n }\n}\n\nfunction isStale(result: FactoryTransitionResult): result is FactoryTransitionResultRejected {\n return result.status === 'rejected' && result.code === 'stale';\n}\n\n/** Tell the caller where the card is now, so a model doesn't read \"stale\" as \"already moved\". */\nfunction staleRejection(result: FactoryTransitionResultRejected, current: Card): FactoryTransitionResult {\n const stage = currentStage(current.stages) ?? current.stages.join(', ');\n return rejection(\n result.transitionId,\n result.itemId,\n 'stale',\n `The card changed (now revision ${current.revision}, in ${stage}). Retry with expectedRevision ${current.revision} if the move still applies.`,\n );\n}\n\nexport function currentStage(stages: readonly string[]): FactoryRuleStage | undefined {\n return stages.length === 1 ? stages[0] : undefined;\n}\n\ninterface TransitionConsentOptions {\n autonomy?: 'arm' | 'disarm';\n consentedBy?: string;\n /** A person moved a card into its board's build seat from before it (see {@link acceptsWork}): that move approves the work. */\n accepted?: boolean;\n}\n\n/**\n * Whether moving a card from `from` to `to` hands it to the board's builder for the first time: `to`\n * runs in the seat of the board's build phase ({@link boardFlow}), and `from` is a resting phase or a\n * working phase of another seat that is no review (Work: Intake or Triage into Planning or Building).\n */\nfunction acceptsWork(board: InstalledBoard, from: string, to: string): boolean {\n const buildRole = boardFlow(board).buildRole;\n if (!buildRole || board.roleForPhase(to) !== buildRole) return false;\n const fromPhase = board.phases[from];\n if (!fromPhase || fromPhase.kind === 'terminal') return false;\n if (fromPhase.kind === 'resting') return true;\n const fromRole = fromPhase.runner.context;\n return fromRole !== buildRole && fromRole !== REVIEW_CONTEXT;\n}\n\n// Entering a resting lane disarms whoever rests it; only a person's move into a working lane arms.\nfunction transitionConsent(working: boolean, humanMove: boolean): 'arm' | 'disarm' | undefined {\n if (!working) return 'disarm';\n return humanMove ? 'arm' : undefined;\n}\n\n// An event arriving as data (GitHub, sweeps) never pre-approves the runs its transition queues.\nfunction bearsConsent(actor: FactoryRuleActor): boolean {\n return actor.type === 'human' || actor.type === 'agent';\n}\n\n// Rides the transition's own revision-checked commit, so a stale or rejected commit flips nothing.\nfunction consentEffect(\n request: FactoryTransitionRequest,\n working: boolean,\n humanMove: boolean,\n): TransitionConsentOptions {\n // A provider event (a reopen, a close) is not a person's say-so: whatever a person armed before\n // no longer stands once a route moves the card.\n if (request.eventRoute) return { autonomy: 'disarm' };\n const autonomy = transitionConsent(working, humanMove);\n return bearsConsent(request.actor) ? { autonomy, consentedBy: actorId(request.actor) } : { autonomy };\n}\n\ntype RunStartDecision = Extract<FactoryCommitDecision, { type: 'invokeSkill' | 'sendMessage' }>;\n\nfunction startsRun(decision: FactoryCommitDecision): decision is RunStartDecision {\n return decision.type === 'invokeSkill' || (decision.type === 'sendMessage' && decision.prepareBinding === true);\n}\n\n// Answering a recorded run start, or the role's own mid-run agent, with a run would start a second one.\n// A run that starts after its own agent's move is queued onto that agent's run instead.\nfunction runAlreadyUnderway(request: FactoryTransitionRequest, decision: RunStartDecision): boolean {\n if (request.cause === 'run_start') return true;\n if (decision.type === 'invokeSkill' && decision.startsAfterOwnMove === true) return false;\n return request.actor.type === 'agent' && request.actor.role === decision.role;\n}\n\nfunction stageTransitionMessage(fromStage: FactoryRuleStage, toStage: FactoryRuleStage): string {\n return `This work was moved from the ${fromStage} stage to the ${toStage} stage.`;\n}\n\nfunction isHumanTransition(request: FactoryTransitionRequest): boolean {\n return request.actor.type === 'human' && request.ingress.type === 'human';\n}\n\nfunction ruleFailure(error: unknown): { code: FactoryRuleRejectionCode; reason: string } {\n return {\n code: 'rule_error',\n reason: error instanceof Error ? `Factory rule failed: ${error.message}` : 'Factory rule failed.',\n };\n}\n\nasync function withRuleTimeout<T>(operation: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error('FACTORY_RULE_TIMEOUT')), timeoutMs);\n });\n try {\n return await Promise.race([operation, timeout]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nexport class FactoryTransitionService {\n readonly #configVersion: string;\n readonly #boards: ProjectBoardSource;\n readonly #storage: WorkItemsStorage;\n readonly #timeoutMs: number;\n readonly #onTerminalStage: FactoryTransitionServiceOptions['onTerminalStage'];\n readonly #onContextLeft: FactoryTransitionServiceOptions['onContextLeft'];\n readonly #terminalCleanupTimeoutMs: number;\n readonly #onAccepted: FactoryTransitionServiceOptions['onAccepted'];\n readonly #onTransitionCommitted: FactoryTransitionServiceOptions['onTransitionCommitted'];\n readonly #audit: AuditRecorder | undefined;\n readonly #runInFlight: FactoryTransitionServiceOptions['runInFlight'];\n\n constructor(options: FactoryTransitionServiceOptions) {\n this.#configVersion = options.configVersion;\n this.#boards = toBoardSource(options.boards);\n this.#storage = options.storage;\n this.#audit = options.audit;\n this.#timeoutMs = options.timeoutMs ?? RULE_TIMEOUT_MS;\n this.#onTerminalStage = options.onTerminalStage;\n this.#onContextLeft = options.onContextLeft;\n this.#onAccepted = options.onAccepted;\n this.#onTransitionCommitted = options.onTransitionCommitted;\n this.#runInFlight = options.runInFlight;\n this.#terminalCleanupTimeoutMs = options.terminalCleanupTimeoutMs ?? TERMINAL_CLEANUP_TIMEOUT_MS;\n }\n\n get configVersion(): string {\n return this.#configVersion;\n }\n\n async transition(request: FactoryTransitionRequest): Promise<FactoryTransitionResult> {\n const replay = await this.#storage.getTransitionResultByIngress(\n request.orgId,\n request.factoryProjectId,\n request.ingress.identity,\n );\n if (replay) return replay as unknown as FactoryTransitionResult;\n\n const transitionId = request.ingress.transitionId ?? globalThis.crypto.randomUUID();\n const item = await this.#storage.get({ orgId: request.orgId, id: request.workItemId });\n if (!item) {\n const rejection = await this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'Work item not found.',\n );\n await this.#recordTransition(request, undefined, rejection);\n return rejection;\n }\n let result = await this.#evaluateAndCommit(request, transitionId, item);\n if (isStale(result)) {\n const current = await this.#storage.get({ orgId: request.orgId, id: request.workItemId });\n if (current) result = staleRejection(result, current);\n }\n await this.#recordTransition(request, item, result);\n this.#notifyCommitted(request, item, result);\n return result;\n }\n\n #notifyCommitted(request: FactoryTransitionRequest, item: Card, result: FactoryTransitionResult): void {\n const onTransitionCommitted = this.#onTransitionCommitted;\n if (!onTransitionCommitted || result.status !== 'accepted') return;\n // Board-neutral: `currentStage` only knows the built-in rule stages.\n const fromStage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (result.stage === fromStage) return;\n // Inside the chain so a synchronous throw is isolated the same way an async rejection is.\n void Promise.resolve()\n .then(() =>\n onTransitionCommitted({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: item.id,\n fromStage,\n toStage: result.stage,\n }),\n )\n .catch(error => {\n console.warn(`[factory] stage notification failed for work item ${item.id}:`, error);\n });\n }\n\n /** A rejection can outlive its work item: the row still names the id the caller asked for. */\n async #recordTransition(\n request: FactoryTransitionRequest,\n item: Card | undefined,\n result: FactoryTransitionResult,\n ): Promise<void> {\n if (!this.#audit) return;\n // Board-neutral, like the stage notification: `currentStage` only knows the\n // built-in rule stages and would drop custom-board phases.\n const from = item && item.stages.length === 1 ? item.stages[0] : undefined;\n if (result.status === 'accepted' && result.stage === from && !request.reenter) return;\n const outcome =\n result.status === 'accepted'\n ? { action: 'factory.work_item.stage_moved' as const, to: result.stage, revision: result.revision }\n : {\n action: 'factory.work_item.transition_rejected' as const,\n to: request.stage,\n code: result.code,\n reason: result.reason,\n };\n const { action, ...detail } = outcome;\n await this.#audit\n .record({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n ...auditActorOf(request.actor),\n actorProfile: request.actorProfile,\n ...(request.context ? { context: request.context } : {}),\n action,\n idempotencyKey: result.transitionId,\n targets: [{ type: 'work_item', id: item?.id ?? request.workItemId, ...(item ? { name: item.title } : {}) }],\n metadata: {\n transitionId: result.transitionId,\n ingressType: request.ingress.type,\n cause: request.cause,\n configVersion: this.#configVersion,\n ...(from ? { from } : {}),\n ...(request.reenter ? { reenter: true } : {}),\n ...detail,\n },\n })\n .catch(error => {\n console.warn(`[factory] audit failed for transition ${result.transitionId}:`, error);\n });\n }\n\n async #evaluateAndCommit(\n request: FactoryTransitionRequest,\n transitionId: string,\n item: Card,\n ): Promise<FactoryTransitionResult> {\n const boards = await this.#boards.load(request);\n if (request.causalChain && request.causalChain.length > MAX_FACTORY_RULE_CAUSAL_DEPTH) {\n return this.#commitRejection(\n request,\n transitionId,\n 'causal_depth_exceeded',\n 'Factory rule causal depth exceeded.',\n );\n }\n const itemSource = workItemSource(item.externalSource);\n const source = factoryRuleSourceForWorkItem(itemSource);\n const isPullRequest = source === 'pullRequest' || source === 'gitlabPullRequest';\n // Rows filed before boards were persisted belong to the default board.\n if (item.board === null && !boards.has(DEFAULT_BOARD_ID)) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'This legacy work item has no assigned board. Assign an installed board and phase through the work-item PATCH endpoint before transitioning it.',\n );\n }\n const itemBoard = boardForWorkItem(item);\n if (request.board !== itemBoard) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `The work item belongs to board \"${itemBoard}\", not \"${request.board}\".`,\n );\n }\n const fromBoard = boards.get(request.board);\n if (!fromBoard) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `Board \"${request.board}\" is not installed.`,\n );\n }\n if (request.toBoard !== undefined && !request.eventRoute) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'Only a card-move rule can move a card to another board.',\n );\n }\n const targetBoard = request.toBoard ?? request.board;\n const board = targetBoard === request.board ? fromBoard : boards.get(targetBoard);\n if (!board) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `Board \"${targetBoard}\" is not installed.`,\n );\n }\n const fromStage = item.stages.length === 1 ? item.stages[0] : undefined;\n if (!fromStage || !Object.prototype.hasOwnProperty.call(fromBoard.phases, fromStage)) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n 'The work item does not have one canonical phase on the requested board.',\n );\n }\n // The board's own reason comes first: its phase graph alone only says the move is not\n // declared, which leaves an agent moving an issue card to PR review guessing why.\n const cardShapeRejection = pullRequestCardRejection(\n board,\n {\n standalonePullRequest: isPullRequest,\n hasPullRequest: hasPullRequest({ workItem: item.workItem, source: itemSource }),\n },\n request.stage,\n );\n if (cardShapeRejection) {\n return this.#commitRejection(request, transitionId, 'invalid_transition', cardShapeRejection);\n }\n if (\n !Object.prototype.hasOwnProperty.call(board.phases, request.stage) ||\n (!request.eventRoute && !board.allowsTransition(fromStage, request.stage))\n ) {\n if (board !== fromBoard) {\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `The ${board.name} board has no phase ${request.stage}.`,\n );\n }\n const nextStages = [...new Set((board.transitions[fromStage] ?? []).map(transition => transition.to))];\n const nextStagesReason =\n nextStages.length > 0\n ? `Next stages declared from ${fromStage}: ${nextStages.join(', ')}.`\n : `No next stage is declared from ${fromStage}.`;\n return this.#commitRejection(\n request,\n transitionId,\n 'invalid_transition',\n `The ${board.name} board does not allow moving from ${fromStage} to ${request.stage}. ${nextStagesReason}`,\n );\n }\n\n if (\n isHumanTransition(request) &&\n request.cause !== 'run_start' &&\n !request.initialEntry &&\n (fromStage !== request.stage || request.reenter === true) &&\n phaseMayStartRun(board.phaseKind(request.stage)) &&\n (await this.#cardBusy(request))\n ) {\n return this.#commitRejection(request, transitionId, 'card_busy', BUSY_CARD_MOVE_REFUSAL);\n }\n\n // The coordinator's own self-move at run start would otherwise inject a second run's kickoff.\n const humanMove = request.actor.type === 'human' && fromStage !== request.stage && request.cause !== 'run_start';\n // The board, not the phase name, says whether a seat is engaged on either side of this move.\n const entersWorking = board.isWorking(request.stage);\n const seatRole = board.roleForPhase(request.stage);\n\n const contextBase = {\n tenant: { orgId: request.orgId, projectId: request.factoryProjectId },\n actor: request.actor,\n ingress: { type: request.ingress.type, id: request.ingress.identity },\n cause: request.cause,\n causalChain: request.causalChain ?? [],\n configVersion: this.#configVersion,\n item: {\n id: item.id,\n source: itemSource,\n sourceKey: item.externalSource\n ? `${item.externalSource.integrationId}:${item.externalSource.type}:${item.externalSource.externalId}`\n : null,\n parentWorkItemId: item.parentWorkItemId,\n title: item.title,\n url: item.externalSource?.url ?? null,\n stages: [...item.stages],\n workItem: item.workItem,\n acceptedAt: item.acceptedAt,\n metadata: item.metadata,\n },\n board: board.id,\n itemRevision: item.revision,\n source,\n fromStage,\n toStage: request.stage,\n } satisfies Omit<FactoryStageRuleContext, 'stage'>;\n\n let evaluation:\n | { outcome: 'accepted'; decisions: Record<string, unknown>[]; intents: TransitionConsentOptions }\n | { outcome: 'rejected'; code: string; reason: string };\n try {\n evaluation = await withRuleTimeout(\n (async () => {\n // Plans are approved without a person only where the card's phase auto-approves submit_plan.\n const plansAutoApproved = autoApprovedExitTool(boards, item) === 'submit_plan';\n // A phase with an exit tool holds the card until the tool succeeds (for submit_plan, with\n // an approved plan; autoApprove only decides whether it approves itself). Then the agent,\n // or the board's own rule for the tool, moves the card. A person can move it any time.\n const fromPhase = fromBoard.phases[fromStage];\n const exitTool = fromPhase?.kind === 'working' ? fromPhase.exitTool : undefined;\n if (\n request.actor.type !== 'human' &&\n // A start lands the card where its run already is; it is not the agent leaving a phase.\n request.cause !== 'run_start' &&\n !request.eventRoute &&\n exitTool &&\n fromStage !== request.stage &&\n entersWorking &&\n !(exitTool.id === 'submit_plan' ? request.planApproved === true : request.completedTool === exitTool.id) &&\n !exitToolSucceeded(item, fromStage, exitTool.id)\n ) {\n return {\n outcome: 'rejected' as const,\n code: 'approval_required',\n reason:\n exitTool.id === 'submit_plan'\n ? `${fromPhase!.name} ends when submit_plan comes back with an approved plan; until then the card stays here. Call submit_plan and wait for a person to approve the plan (or for it to be approved automatically), then move the card into ${board.phases[request.stage]?.name ?? request.stage} with factory_transition_work_item.`\n : `${fromPhase!.name} ends when ${exitTool.id} succeeds; until then the card stays here. A person can also move it from the Factory board or a chat they are signed in to.`,\n };\n }\n const policy = boardTransitionPolicyResultSchema.parse(\n await board.transitionPolicy?.(\n immutablePolicySnapshot({\n ...contextBase,\n item: { ...contextBase.item, triageType: item.triageType },\n initialEntry: request.initialEntry ?? false,\n reenter: request.reenter ?? false,\n isHumanTransition: isHumanTransition(request),\n plansAutoApproved,\n planApproved: request.planApproved === true,\n requestedTriageType: undefined,\n }),\n ),\n );\n if (policy?.type === 'reject') {\n return { outcome: 'rejected' as const, code: policy.code, reason: policy.reason };\n }\n const run = phaseRunDecision(board, request.stage, contextBase, {\n initialEntry: request.initialEntry,\n reenter: request.reenter,\n });\n const validated = validateFactoryRuleDecisions(run ? [run] : [], contextBase.causalChain.length).filter(\n decision => {\n assertFactoryDecisionTarget(decision, boards, board.id);\n return !(startsRun(decision) && runAlreadyUnderway(request, decision));\n },\n );\n if (humanMove) {\n const message = stageTransitionMessage(fromStage, request.stage);\n const skill = validated.find(decision => decision.type === 'invokeSkill');\n if (skill) {\n skill.precedingMessage = message;\n } else {\n validated.unshift({\n type: 'sendMessage',\n idempotencyKey: `factory-stage:${transitionId}`,\n message,\n priority: 'urgent',\n idleBehavior: 'wake',\n // Parking a card says stop: no seat is right by construction, so\n // the notice goes to whichever session is live — or nobody.\n ...(entersWorking && seatRole !== undefined ? { role: seatRole, prepareBinding: true } : {}),\n });\n }\n }\n return {\n outcome: 'accepted' as const,\n intents: {\n accepted: isHumanTransition(request) && acceptsWork(board, fromStage, request.stage),\n },\n decisions: validateFactoryRuleDecisions(validated) as unknown as Record<string, unknown>[],\n };\n })(),\n this.#timeoutMs,\n );\n } catch (error) {\n const failed =\n error instanceof Error && error.message === 'FACTORY_RULE_TIMEOUT'\n ? { code: 'timeout' as const, reason: 'Factory rule evaluation timed out.' }\n : ruleFailure(error);\n evaluation = { outcome: 'rejected', ...failed };\n }\n return this.#commit(\n request,\n transitionId,\n evaluation,\n evaluation.outcome === 'accepted'\n ? { ...consentEffect(request, entersWorking, humanMove), ...evaluation.intents }\n : {},\n boards,\n fromStage,\n );\n }\n\n /** A run in flight on the card's sessions, or one queued for it: what the board shows as busy. */\n async #cardBusy(request: FactoryTransitionRequest): Promise<boolean> {\n const queued = await this.#storage.listDeferredDecisions(request.orgId, request.factoryProjectId, {\n statuses: ['pending', 'retry', 'leased'],\n workItemId: request.workItemId,\n });\n if (queued.some(decision => isRunBearingDecision(decision.decision))) return true;\n return (await this.#runInFlight?.(request)) ?? false;\n }\n\n async #commitRejection(\n request: FactoryTransitionRequest,\n transitionId: string,\n code: FactoryRuleRejectionCode,\n reason: string,\n ): Promise<FactoryTransitionResult> {\n return this.#commit(\n request,\n transitionId,\n { outcome: 'rejected', code, reason: reason.slice(0, MAX_REJECTION_REASON) },\n {},\n undefined,\n );\n }\n\n async #commit(\n request: FactoryTransitionRequest,\n transitionId: string,\n evaluation:\n | { outcome: 'accepted'; decisions: Record<string, unknown>[] }\n | { outcome: 'rejected'; code: string; reason: string },\n options: TransitionConsentOptions,\n // The registry the move was evaluated against; rejected moves never release resources.\n boards: BoardRegistry | undefined,\n fromStage?: string,\n ): Promise<FactoryTransitionResult> {\n const committed = await this.#storage.commitTransition({\n autonomy: options.autonomy,\n consentedBy: options.consentedBy,\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n expectedRevision: request.expectedRevision,\n destinationStage: request.stage,\n ...(request.toBoard !== undefined && request.toBoard !== request.board\n ? { destinationBoard: request.toBoard }\n : {}),\n actorId: actorId(request.actor),\n ingress: { identity: request.ingress.identity, transitionId },\n causalChain: [...(request.causalChain ?? [])],\n evaluation,\n });\n if (committed.status === 'missing') {\n return rejection(transitionId, request.workItemId, 'invalid_transition', 'Work item not found.');\n }\n const result = committed.result as unknown as FactoryTransitionResult;\n if (\n this.#onAccepted &&\n options.accepted &&\n committed.status === 'committed' &&\n result.status === 'accepted' &&\n committed.item\n ) {\n const item = committed.item;\n const onAccepted = this.#onAccepted;\n // Invoke inside the chain so a synchronous throw is isolated the same way an async rejection is.\n void Promise.resolve()\n .then(() =>\n onAccepted({\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n item,\n }),\n )\n .catch(error => {\n console.warn(`[factory] acceptance hook failed for work item ${request.workItemId}:`, error);\n });\n }\n // Only an installed board's declaration releases resources; an unknown board or phase never does.\n const board = result.status === 'accepted' ? boards?.get(request.toBoard ?? request.board) : undefined;\n if (board && result.status === 'accepted') {\n const crossesBoards = request.toBoard !== undefined && request.toBoard !== request.board;\n const hooks = {\n orgId: request.orgId,\n factoryProjectId: request.factoryProjectId,\n workItemId: request.workItemId,\n revision: result.revision,\n actor: request.actor,\n };\n if (board.isTerminal(result.stage)) {\n const onTerminalStage = this.#onTerminalStage;\n if (onTerminalStage) await this.#bounded(() => onTerminalStage({ ...hooks, stage: result.stage }));\n } else if (fromStage !== undefined && this.#onContextLeft) {\n const context = boards?.get(request.board)?.roleForPhase(fromStage);\n const toContext = board.roleForPhase(result.stage);\n const onContextLeft = this.#onContextLeft;\n // Leaving the board leaves its context even under the same role name; the hook keeps a\n // session the card's new phase still holds.\n if (context !== undefined && (crossesBoards || context !== toContext)) {\n await this.#bounded(() => onContextLeft({ ...hooks, context, toContext }));\n }\n }\n }\n return result;\n }\n\n /** Run a resource-release hook, waiting at most the cleanup bound; it never fails the committed transition. */\n async #bounded(release: () => Promise<void> | void): Promise<void> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const cleanup = Promise.resolve().then(release);\n // A late rejection after the timeout wins the race must not surface\n // as an unhandled rejection.\n cleanup.catch(() => {});\n await Promise.race([\n cleanup,\n new Promise<void>(resolve => {\n timer = setTimeout(resolve, this.#terminalCleanupTimeoutMs);\n }),\n ]);\n } catch {\n // Resource release is best-effort — never fail a committed transition.\n } finally {\n clearTimeout(timer);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;;;;;AAK7B,MAAM,8BAA8B;AAqHpC,SAAS,UACP,cACA,QACA,MACA,QACyB;CACzB,OAAO;EAAE,QAAQ;EAAY;EAAc;EAAQ;EAAM,QAAQ,OAAO,MAAM,GAAG,oBAAoB;CAAE;AACzG;AAEA,SAAS,QAAQ,OAAiC;CAChD,QAAQ,MAAM,MAAd;EACE,KAAK;EACL,KAAK,UACH,OAAO,MAAM;EACf,KAAK,SACH,OAAO,SAAS,MAAM;EACxB,KAAK,UACH,OAAO,UAAU,MAAM;EACzB,KAAK,UACH,OAAO,UAAU,MAAM;CAC3B;AACF;AAGA,SAAgB,aAAa,OAAyE;CACpG,MAAM,KAAK,QAAQ,KAAK;CACxB,QAAQ,MAAM,MAAd;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Ac,YAAW;IAC3B,QAAQ,WAAW,SAAS,KAAK,yBAAyB;GAC5D,CAAC,CACH,CAAC;EACH,QAAQ,CAER,UAAU;GACR,aAAa,KAAK;EACpB;CACF;AACF"}
|
package/dist/rules/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare function isFactoryTriageType(value: unknown): value is FactoryTri
|
|
|
32
32
|
export type FactoryRuleBoard = string;
|
|
33
33
|
export declare const FACTORY_RULE_SOURCES: readonly ['issue', 'pullRequest', 'gitlabIssue', 'gitlabPullRequest', 'linearIssue', 'jiraIssue', 'incidentioFollowUp', 'dependabotAlert', 'vantaVulnerability', 'detailFinding', 'manual'];
|
|
34
34
|
export type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];
|
|
35
|
-
export declare const FACTORY_GITHUB_EVENTS: readonly ['issueOpened', 'issueEdited', 'issueClosed', 'issueReopened', 'issueCommentCreated', 'issueCommentEdited', 'issueCommentDeleted', 'pullRequestOpened', 'pullRequestUpdated', 'pullRequestCommentCreated', 'pullRequestReviewRequested', 'pullRequestReviewSubmitted', 'pullRequestMerged', 'pullRequestClosed'];
|
|
35
|
+
export declare const FACTORY_GITHUB_EVENTS: readonly ['issueOpened', 'issueEdited', 'issueClosed', 'issueReopened', 'issueCommentCreated', 'issueCommentEdited', 'issueCommentDeleted', 'pullRequestOpened', 'pullRequestUpdated', 'pullRequestCommentCreated', 'pullRequestReviewRequested', 'pullRequestReviewSubmitted', 'pullRequestMerged', 'pullRequestClosed', 'pullRequestReopened'];
|
|
36
36
|
export type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];
|
|
37
37
|
export declare const FACTORY_GITLAB_EVENTS: readonly ['issueOpened', 'issueUpdated', 'issueClosed', 'issueReopened', 'issueCommented', 'mergeRequestOpened', 'mergeRequestUpdated', 'mergeRequestCommented', 'mergeRequestMerged', 'mergeRequestClosed'];
|
|
38
38
|
export type FactoryGitLabEventName = (typeof FACTORY_GITLAB_EVENTS)[number];
|
|
@@ -78,6 +78,12 @@ export type FactoryRuleActor = {
|
|
|
78
78
|
login: string;
|
|
79
79
|
trusted: boolean;
|
|
80
80
|
factoryAuthored: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether GitHub typed the sender as a person (`User`), not an app or bot.
|
|
83
|
+
* Absent on events Factory synthesizes itself and on actors recorded before
|
|
84
|
+
* it existed: neither says a person sent them.
|
|
85
|
+
*/
|
|
86
|
+
human?: boolean;
|
|
81
87
|
} | {
|
|
82
88
|
type: 'gitlab';
|
|
83
89
|
username: string;
|
|
@@ -524,7 +530,9 @@ export interface FactoryVantaRuleContext extends FactoryRuleContextBase {
|
|
|
524
530
|
};
|
|
525
531
|
}
|
|
526
532
|
export type FactoryRuleHandler<TContext> = (context: Readonly<TContext>) => FactoryRuleDecision | void | Promise<FactoryRuleDecision | void>;
|
|
527
|
-
export type FactoryRuleRejectionCode = 'forbidden' | 'invalid_transition' | 'missing_binding' | 'stale' | 'timeout' | 'rule_error' | 'causal_depth_exceeded' | 'repeated_transition' | 'approval_required'
|
|
533
|
+
export type FactoryRuleRejectionCode = 'forbidden' | 'invalid_transition' | 'missing_binding' | 'stale' | 'timeout' | 'rule_error' | 'causal_depth_exceeded' | 'repeated_transition' | 'approval_required'
|
|
534
|
+
/** A person moved a card into a phase that may start a run while a run is in flight on it or queued for it. */
|
|
535
|
+
| 'card_busy';
|
|
528
536
|
export interface FactoryRuleRejectDecision {
|
|
529
537
|
type: 'reject';
|
|
530
538
|
code: FactoryRuleRejectionCode;
|
|
@@ -572,6 +580,11 @@ export interface FactoryTransitionDecision extends FactoryCommitDecisionBase {
|
|
|
572
580
|
export interface FactoryRouteEventDecision extends FactoryCommitDecisionBase {
|
|
573
581
|
type: 'routeEvent';
|
|
574
582
|
event: BoardEventFacts;
|
|
583
|
+
/**
|
|
584
|
+
* An update the card's own session made (its labels or assignees, set through Factory): held
|
|
585
|
+
* until the session's run ends, then combined with the session's other updates into one event.
|
|
586
|
+
*/
|
|
587
|
+
fromCardSession?: true;
|
|
575
588
|
}
|
|
576
589
|
/**
|
|
577
590
|
* Tells the card's live session that its source saw activity, such as a new
|
|
@@ -631,9 +644,9 @@ export interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisi
|
|
|
631
644
|
workItemId: string;
|
|
632
645
|
};
|
|
633
646
|
/**
|
|
634
|
-
* The card of the issue this pull or merge request closes. When no card holds the record yet
|
|
635
|
-
* the
|
|
636
|
-
* `
|
|
647
|
+
* The card of the issue this pull or merge request closes. When no card holds the record yet and
|
|
648
|
+
* that card is unfinished, the record links to it, whoever authored it, and the card gets a
|
|
649
|
+
* `pull_request.opened` for its board's card-move rules; otherwise it is filed as usual.
|
|
637
650
|
*/
|
|
638
651
|
closesIssue?: {
|
|
639
652
|
workItemId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAErF,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,WAAW,GACX,cAAc,GACd,WAAW,GACX,cAAc,GACd,YAAY,GACZ,sBAAsB,GACtB,yBAAyB,GACzB,qBAAqB,GACrB,gBAAgB,GAChB,QAAQ,CAAC;AAEb,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,GACX,sBAAsB,CAwBxB;AAED,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAKzD,wBAAgB,aAAa,CAC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AIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,yBAAyB;IACnF,IAAI,EAAE,qBAAqB,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,qBAAqB,GAC7B,yBAAyB,GACzB,yBAAyB,GACzB,6BAA6B,GAC7B,kCAAkC,GAClC,mCAAmC,GACnC,0BAA0B,GAC1B,0BAA0B,GAC1B,qBAAqB,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,GAAG,qBAAqB,CAAC;AAEpF,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,qBAAqB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG,+BAA+B,GAAG,+BAA+B,CAAC;AAExG,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAyBtF"}
|
package/dist/rules/types.js
CHANGED
package/dist/rules/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/rules/types.ts"],"sourcesContent":["import type { ActivityEvent, BoardEventFacts } from '../boards/board-events.js';\nimport type { ExternalWorkItemSource } from '../storage/domains/work-items/base.js';\nimport type { WorkItemRow } from '../storage/domains/work-items/work-item-schema.js';\n\nexport type WorkItemSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'github-dependabot-alert'\n | 'vanta-vulnerability'\n | 'detail-finding'\n | 'manual';\n\nexport function externalSourceForWorkItem(\n source: WorkItemSource,\n sourceKey: string,\n url?: string,\n): ExternalWorkItemSource {\n const [integrationId, type] =\n source === 'github-pr'\n ? ['github', 'pull-request']\n : source === 'github-issue'\n ? ['github', 'issue']\n : source === 'gitlab-pr'\n ? ['gitlab', 'pull-request']\n : source === 'gitlab-issue'\n ? ['gitlab', 'issue']\n : source === 'linear-issue'\n ? ['linear', 'issue']\n : source === 'jira-issue'\n ? ['jira', 'issue']\n : source === 'incidentio-follow-up'\n ? ['incidentio', 'issue']\n : source === 'github-dependabot-alert'\n ? ['github', 'dependabot-alert']\n : source === 'vanta-vulnerability'\n ? ['vanta', 'vulnerability']\n : source === 'detail-finding'\n ? ['detail', 'finding']\n : ['factory', 'manual'];\n return { integrationId, type, externalId: sourceKey, ...(url ? { url } : {}) };\n}\n\n/** The source label that holds an issue at rest until a maintainer decides; compared lowercased. */\nexport const NEEDS_APPROVAL_LABEL = 'status: needs approval';\n\n/** Request-changes rounds from self-review before the card parks in Intake for a person. */\nexport const SELF_REVIEW_ROUND_LIMIT = 3;\nexport const AUTO_TRIAGED_LABEL = 'status: auto-triaged';\n\n// The label only holds a card nobody accepted yet (`awaitsAcceptance`, see the boards'\n// `awaitsAcceptance`): once a person moves it into a working lane, the label is stale until the\n// source catches up (Factory removes it on that move).\nexport function needsApproval(\n item: { workItem: Pick<WorkItemRow, 'labels'>; stages?: readonly string[] },\n awaitsAcceptance: (stage: string) => boolean,\n): boolean {\n const labels = item.workItem.labels;\n if (!Array.isArray(labels)) return false;\n return (\n labels.some(label => typeof label === 'string' && label.toLowerCase() === NEEDS_APPROVAL_LABEL) &&\n (item.stages ?? []).every(awaitsAcceptance)\n );\n}\n\nexport function workItemSource(source: ExternalWorkItemSource | null): WorkItemSource {\n if (!source) return 'manual';\n if (source.integrationId === 'linear') return 'linear-issue';\n if (source.integrationId === 'gitlab') return source.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n if (source.integrationId === 'jira') return 'jira-issue';\n if (source.integrationId === 'incidentio') return 'incidentio-follow-up';\n if (source.integrationId === 'vanta') return 'vanta-vulnerability';\n if (source.integrationId === 'detail') return 'detail-finding';\n // Only GitHub, GitLab, Linear, Jira, and incident.io have provider-specific\n // rules; anything else (a Slack thread, say) is a plain work item, not a\n // mislabeled GitHub issue.\n if (source.integrationId !== 'github') return 'manual';\n if (source.type === 'dependabot-alert') return 'github-dependabot-alert';\n return source.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\n/** The card's author is inside the write-access circle, or the card is Factory's own PR. */\nexport function authorTrusted(metadata: Record<string, unknown> | null | undefined): boolean {\n return metadata?.authorTrusted === true || metadata?.factoryAuthored === true;\n}\n\n// Authored outside the write-access circle: a missing trust stamp fails closed until\n// the reconcile sweep backfills it, and Factory's own PRs pass through `factoryAuthored`.\nexport function externallyAuthored(item: { source: string; metadata: Record<string, unknown> | null }): boolean {\n if (!['github-pr', 'github-issue', 'gitlab-pr', 'gitlab-issue'].includes(item.source)) return false;\n return !authorTrusted(item.metadata);\n}\n\nexport function externallyAuthoredWorkItem(item: {\n externalSource: ExternalWorkItemSource | null;\n metadata: Record<string, unknown> | null;\n}): boolean {\n return externallyAuthored({ source: workItemSource(item.externalSource), metadata: item.metadata });\n}\n\n/** A phase key on the card's board. Boards name their own phases; Factory reads none of them by name. */\nexport type FactoryRuleStage = string;\n\nexport const FACTORY_TRIAGE_TYPES = [\n 'bug',\n 'feature request',\n 'docs',\n 'question/support',\n 'maintenance',\n 'duplicate',\n 'resolved',\n 'invalid',\n 'spam',\n 'out-of-scope',\n 'other',\n] as const;\nexport type FactoryTriageType = (typeof FACTORY_TRIAGE_TYPES)[number];\n\nexport function isFactoryTriageType(value: unknown): value is FactoryTriageType {\n return typeof value === 'string' && FACTORY_TRIAGE_TYPES.some(type => type === value);\n}\n\n/** A board id. */\nexport type FactoryRuleBoard = string;\n\nexport const FACTORY_RULE_SOURCES = [\n 'issue',\n 'pullRequest',\n 'gitlabIssue',\n 'gitlabPullRequest',\n 'linearIssue',\n 'jiraIssue',\n 'incidentioFollowUp',\n 'dependabotAlert',\n 'vantaVulnerability',\n 'detailFinding',\n 'manual',\n] as const;\nexport type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];\n\nexport const FACTORY_GITHUB_EVENTS = [\n 'issueOpened',\n 'issueEdited',\n 'issueClosed',\n 'issueReopened',\n 'issueCommentCreated',\n 'issueCommentEdited',\n 'issueCommentDeleted',\n 'pullRequestOpened',\n 'pullRequestUpdated',\n 'pullRequestCommentCreated',\n 'pullRequestReviewRequested',\n 'pullRequestReviewSubmitted',\n 'pullRequestMerged',\n 'pullRequestClosed',\n] as const;\nexport type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];\n\nexport const FACTORY_GITLAB_EVENTS = [\n 'issueOpened',\n 'issueUpdated',\n 'issueClosed',\n 'issueReopened',\n 'issueCommented',\n 'mergeRequestOpened',\n 'mergeRequestUpdated',\n 'mergeRequestCommented',\n 'mergeRequestMerged',\n 'mergeRequestClosed',\n] as const;\nexport type FactoryGitLabEventName = (typeof FACTORY_GITLAB_EVENTS)[number];\n\nexport const FACTORY_LINEAR_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryLinearEventName = (typeof FACTORY_LINEAR_EVENTS)[number];\n\nexport const FACTORY_JIRA_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryJiraEventName = (typeof FACTORY_JIRA_EVENTS)[number];\n\nexport const FACTORY_INCIDENTIO_EVENTS = ['followUpObserved', 'followUpClosed'] as const;\nexport type FactoryIncidentioEventName = (typeof FACTORY_INCIDENTIO_EVENTS)[number];\n\nexport const FACTORY_DEPENDABOT_EVENTS = ['alertObserved', 'alertClosed'] as const;\nexport type FactoryDependabotEventName = (typeof FACTORY_DEPENDABOT_EVENTS)[number];\nexport const FACTORY_VANTA_EVENTS = ['vulnerabilityObserved', 'vulnerabilityClosed'] as const;\nexport type FactoryVantaEventName = (typeof FACTORY_VANTA_EVENTS)[number];\n\nexport type FactoryRuleJsonValue =\n | null\n | boolean\n | number\n | string\n | FactoryRuleJsonValue[]\n | { [key: string]: FactoryRuleJsonValue };\n\nexport interface FactoryRuleItemContext {\n workItem: WorkItemRow;\n id: string;\n source: WorkItemSource;\n sourceKey: string | null;\n parentWorkItemId: string | null;\n title: string;\n url: string | null;\n stages: readonly string[];\n /**\n * @deprecated Factory no longer records triage acceptance; this is the value stamped on older\n * cards, and `null` for every card since. A person moving the card on is the approval.\n */\n acceptedAt: Date | null;\n /** Factory-owned process state and trust stamps. */\n metadata: Record<string, unknown> | null;\n}\n\nexport type FactoryRuleActor =\n | { type: 'human'; id: string }\n | { type: 'agent'; bindingId: string; role: string }\n | { type: 'github'; login: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'gitlab'; username: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'system'; id: string };\n\nexport interface FactoryRuleIngressIdentity {\n type: 'human' | 'agent' | 'toolResult' | 'github' | 'gitlab' | 'linear' | 'jira' | 'incidentio' | 'vanta' | 'rule';\n id: string;\n}\n\nexport interface FactoryRuleCausalEntry {\n ingressId: string;\n decisionType: FactoryCommitDecision['type'];\n}\n\n/** The phase a card sits in, as its board declares it. */\nexport interface FactoryRulePhaseContext {\n id: string;\n kind: 'resting' | 'working' | 'terminal';\n /** Session context a working phase runs in; absent for resting and terminal phases. */\n context?: string;\n /** @deprecated Use `context`. */\n role?: string;\n /** Phases the card may move to from here. */\n nextPhases: readonly string[];\n}\n\nexport interface FactoryRuleContextBase {\n tenant: { orgId: string; projectId: string };\n actor: FactoryRuleActor;\n ingress: FactoryRuleIngressIdentity;\n cause: string;\n causalChain: readonly FactoryRuleCausalEntry[];\n configVersion: string;\n}\n\nexport interface FactoryBoundRuleContext extends FactoryRuleContextBase {\n item: FactoryRuleItemContext;\n board: FactoryRuleBoard;\n itemRevision: number;\n}\n\nexport interface FactoryStageRuleContext extends FactoryBoundRuleContext {\n source: FactoryRuleSource;\n stage: FactoryRuleStage;\n fromStage: FactoryRuleStage;\n toStage: FactoryRuleStage;\n}\n\nexport interface FactoryToolResultRuleContext extends FactoryBoundRuleContext {\n toolName: string;\n threadId: string;\n assistantMessageId: string;\n toolCallId: string;\n result: {\n status: 'success' | 'error';\n value: FactoryRuleJsonValue;\n };\n}\n\nexport interface FactoryGithubRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n /**\n * Set on the one evaluation per pull request delivery that files the pull\n * request's own Review card. Opening a pull request concerns two cards — that\n * Review card and the Work item that authored the pull request — so the rule\n * answers for the two separately: the arrival carries this flag and is\n * committed against the authoring item when resolution found one, which is\n * what links the new card to it, while the authoring item's own evaluation\n * leaves the flag unset.\n */\n pullRequestIntake?: boolean;\n /**\n * Set on both evaluations of a pull request's first sighting when it belongs on an existing\n * card: the Work card that authored it (`authored`), or the card of the issue a trusted author's\n * pull request says it closes (`closes`). The pull request is filed on that card as one more\n * source rather than on a card of its own.\n */\n pullRequestHome?: FactoryPullRequestHome;\n event: FactoryGithubEventName;\n deliveryId: string;\n factory: { createdAt: string };\n /** `installationId` is the GitHub App installation the delivery arrived through. */\n repository: { id: number; fullName: string; installationId?: number };\n issue?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n state?: 'open' | 'closed';\n author?: string;\n /** GitHub close reason: `completed`, `not_planned`, or `duplicate`. */\n stateReason?: string;\n };\n issueChange?: { title: boolean; body: boolean };\n issueComment?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n authorType?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n pullRequest?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n requestedReviewers?: string[];\n labels?: string[];\n author?: string;\n factoryAuthored: boolean;\n headBranch: string;\n /** Lowercase head commit SHA, when the delivery carries one. */\n headSha?: string;\n baseBranch: string;\n };\n /** Present on `pullRequestReviewRequested`: who review was (re-)requested from. */\n reviewRequest?: { reviewer: string; factoryReviewer: boolean };\n /** Present when a PR comment uses Factory's exact review command. */\n reviewCommand?: { command: 'review' | 're-review'; target: string };\n /**\n * Present on `pullRequestReviewSubmitted`: the review that was just posted, or a\n * request-changes review whose body was edited to a new Factory verdict.\n */\n review?: { id: number; state: string; url: string; author?: string; body?: string };\n}\n\n/**\n * Where an integration files a new card: the default board's initial phase. The project's intake\n * routes then decide where the card goes; the board and phase a rule names don't. Absent when the\n * default board is not installed.\n */\nexport interface FactoryRuleIntakeTarget {\n board: string;\n initialPhase: string;\n}\n\n/**\n * Where a source-closed rule moves the card, from the `sourceClosed` mapping its installed board\n * declares. Absent when the card's board is not installed or declares no mapping.\n */\nexport interface FactoryRuleBoardClosure {\n /** Title of the card's board, for messages. */\n boardTitle: string;\n /** Terminal phase for a source that was completed. */\n completed: FactoryRuleBoardClosurePhase;\n /** Terminal phase for a source that was canceled or not planned. */\n canceled: FactoryRuleBoardClosurePhase;\n /** Whether the card already sits in a terminal phase of its board. */\n itemTerminal: boolean;\n}\n\nexport interface FactoryRuleBoardClosurePhase {\n phase: string;\n title: string;\n}\n\n/**\n * The phases a card's board runs its pull request loop through, read from what each phase declares\n * (see `boardFlow`). Every field is absent when the board has no such phase.\n */\nexport interface FactoryRuleBoardFlow {\n /** Where a card on the board rests before work starts and goes back to when its pull request is abandoned. */\n readonly initialPhase?: string;\n /** Phase that takes pull requests: reviews them, records verdicts on them, and re-reviews pushes. */\n readonly pullRequestReview?: string;\n /** Working phase that sorts new cards before anyone accepts them: on a board that builds, the first one that neither builds nor reviews. */\n readonly triage?: string;\n /** Working phase that reviews the builder's branch before a pull request opens. */\n readonly selfReview?: string;\n /** Working phase that builds the change and opens the pull request. */\n readonly build?: string;\n /** Seat that runs {@link build}; pull request feedback wakes it. */\n readonly buildRole?: string;\n /** Terminal phase a merge finishes the card in: the board's `sourceClosed.completed`, else its first terminal phase. */\n readonly completed?: Readonly<FactoryRuleBoardClosurePhase>;\n /** Terminal phase a pull request closed unmerged ends its own card in: `sourceClosed.canceled`, else the next terminal phase. */\n readonly canceled?: Readonly<FactoryRuleBoardClosurePhase>;\n}\n\nexport interface FactoryGitLabRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n /** Set on a merge request's first sighting when it is filed on an existing card instead of its own. */\n pullRequestHome?: FactoryPullRequestHome;\n event: FactoryGitLabEventName;\n deliveryId: string;\n factory: { createdAt: string };\n repository: { id: number; fullName: string; host: string };\n issue?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n state?: 'open' | 'closed';\n author?: string;\n authorTrusted: boolean;\n };\n note?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n mergeRequest?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n reviewers?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n author?: string;\n authorTrusted: boolean;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n}\n\nexport interface FactoryLinearRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryLinearEventName;\n issue: {\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n creator: string | null;\n team: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n sourceId?: string | null;\n projectId?: string | null;\n };\n}\n\nexport interface FactoryJiraRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryJiraEventName;\n issue: {\n /** Stable issue reference — the direct integration's Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n project: string | null;\n site: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryIncidentioRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryIncidentioEventName;\n issue: {\n /** Stable item reference — the prefixed incident.io follow-up id the intake feed serves as `id`. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n /** Reference of the incident this follow-up belongs to, when available. */\n incident: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryDependabotRuleContext extends FactoryRuleContextBase {\n /** The status change this sync reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryDependabotEventName;\n alert: {\n /** Stable alert reference — `owner/repo#dependabot-<number>`. */\n id: string;\n number: number;\n repository: string;\n title: string;\n url: string;\n /** `open`, `dismissed`, `fixed`, or `auto_dismissed`. */\n state: string;\n severity: string | null;\n packageName: string | null;\n ecosystem: string | null;\n manifestPath: string | null;\n /** Markdown writeup for the card's description. */\n description: string | null;\n ghsaId: string | null;\n cveId: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryVantaRuleContext extends FactoryRuleContextBase {\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n boardClosure?: FactoryRuleBoardClosure;\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n event: FactoryVantaEventName;\n vulnerability: {\n /** Vanta vulnerability id — one card per vulnerability, not per advisory. */\n id: string;\n /** Advisory name, e.g. `CVE-2026-118764` or `AIKIDO-2026-54683`. */\n name: string;\n title: string;\n description: string | null;\n url: string | null;\n /** `open`, or `resolved` once Vanta no longer lists it as active. */\n state: 'open' | 'resolved';\n severity: string | null;\n packageIdentifier: string | null;\n fixable: boolean | null;\n remediateBy: string | null;\n labels: readonly string[];\n createdAt: string;\n };\n}\n\nexport type FactoryRuleHandler<TContext> = (\n context: Readonly<TContext>,\n) => FactoryRuleDecision | void | Promise<FactoryRuleDecision | void>;\n\nexport type FactoryRuleRejectionCode =\n | 'forbidden'\n | 'invalid_transition'\n | 'missing_binding'\n | 'stale'\n | 'timeout'\n | 'rule_error'\n | 'causal_depth_exceeded'\n | 'repeated_transition'\n | 'approval_required';\n\nexport interface FactoryRuleRejectDecision {\n type: 'reject';\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\ninterface FactoryCommitDecisionBase {\n idempotencyKey: string;\n}\n\nexport interface FactoryTransitionDecision extends FactoryCommitDecisionBase {\n type: 'transition';\n board: FactoryRuleBoard;\n stage: FactoryRuleStage;\n /**\n * Delivered to the item's active session (waking it if idle) after the\n * transition commits. Skipped when the item has no active run binding, so\n * informational messages never fail the transition.\n */\n message?: { text: string; role?: string };\n /**\n * Runs the stage's entry rules even when the item is already in that stage.\n * A transition to the current stage is normally inert, because most callers\n * are correcting a board into a state it already holds. Re-entry is for the\n * opposite case: the stage's work is in flight and has been invalidated, so\n * it has to start over.\n */\n reenter?: boolean;\n /**\n * The status event this move answers. The project's intake routes on the card's board then\n * decide where the card goes instead, and this move applies only when no route on the board\n * handles the event; a route that does, even a disabled one, owns it. Factory drops the tag\n * from a decision returned by an explicit override on the integration's `rules`, so that\n * override's move always applies; a board handler's tagged move still goes to the routes.\n */\n event?: BoardEventFacts;\n}\n\n/**\n * Hands a status event on an existing card to the project's intake routes: the first enabled\n * route on the card's board whose `on` names the event and whose `when` matches moves the card.\n * Integrations add it when no rule decided anything for the delivery; nothing moves when no\n * route matches.\n */\nexport interface FactoryRouteEventDecision extends FactoryCommitDecisionBase {\n type: 'routeEvent';\n event: BoardEventFacts;\n}\n\n/**\n * Tells the card's live session that its source saw activity, such as a new\n * comment or an edit. It carries pointers only: the dispatcher writes the\n * message from these fields, so no provider text (a comment body, a title)\n * ever reaches the session through it. Without a live session it is dropped.\n */\nexport interface FactorySignalActivityDecision extends FactoryCommitDecisionBase {\n type: 'signalActivity';\n event: ActivityEvent;\n /** The source's own reference, such as `acme/app#12`. */\n reference: string;\n url: string;\n author?: string;\n authorTrusted: boolean;\n /**\n * What an idle session does with it. Defaults to `wake`; `persist` leaves it\n * in the session's notifications without starting a run, for sources whose\n * own comments Factory cannot tell apart from other people's. Activity from an\n * untrusted author always persists.\n */\n idleBehavior?: 'wake' | 'persist';\n}\n\n/** The existing card a pull or merge request is filed on; see `pullRequestHome`. */\nexport interface FactoryPullRequestHome {\n workItemId: string;\n reason: 'authored' | 'closes';\n}\n\nexport interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisionBase {\n type: 'upsertLinkedWorkItem';\n board: FactoryRuleBoard;\n source: WorkItemSource;\n sourceKey: string;\n title: string;\n /** The new card's own description. Only seeds a card being created; an existing card's is left alone. */\n description?: string;\n url: string | null;\n stage: FactoryRuleStage;\n /**\n * File the card at `stage` as its first entry and run none of the board's\n * phase rules for it — no arrival, no destination entry. The card is filed\n * (or, if it already exists, moved) and left parked for a person; nothing is\n * started for it. For external records that arrive already past the board's\n * first step: a GitHub issue whose triage is already recorded, for instance.\n *\n * Placement is the whole decision. An existing card it reaches is moved to\n * that stage through the same relocation the label routes use, and its\n * metadata is left alone.\n */\n skipRules?: boolean;\n /**\n * File the pull or merge request on this existing card, the one that authored it, as one more\n * source instead of on a card of its own. Applies only when no card holds the record yet and\n * the card is still open on Work; otherwise the record is filed as usual.\n */\n attachTo?: { workItemId: string };\n /**\n * The card of the issue this pull or merge request closes. When no card holds the record yet,\n * the project's intake routes can test that card and join the record to it (see\n * `IntakeRouteTarget.joinClosedIssue`); otherwise it is filed as usual.\n */\n closesIssue?: { workItemId: string };\n metadata?: Record<string, FactoryRuleJsonValue>;\n}\n\ninterface FactoryInvokeSkillDecisionBase extends FactoryCommitDecisionBase {\n type: 'invokeSkill';\n role: string;\n arguments?: string;\n precedingMessage?: string;\n cancelInFlight?: boolean;\n /**\n * Start this run even when the card was moved by the agent already running in\n * this role's session. The prompt is queued onto that agent's run, so a phase\n * that shares its context with the one before it still gets its own work.\n * Without it, an agent's own move into a phase of its role starts nothing.\n */\n startsAfterOwnMove?: boolean;\n /**\n * Pursue the run's work as a goal: the session's thread holds `objective` until the card\n * leaves the phase, and the agent's goal judge keeps the run going until it is met.\n */\n goal?: { objective: string; maxRuns?: number };\n}\n\n/**\n * Starting an agent run. Most runs activate a skill, because the skill carries\n * the handoff contract later rules match on. A run whose completion is already\n * signalled some other way — Building finishes by opening a pull request, which\n * arrives as its own event — needs no contract, so it can carry a plain prompt\n * instead of an otherwise empty skill.\n */\nexport type FactoryInvokeSkillDecision = FactoryInvokeSkillDecisionBase &\n (\n | {\n skillName: string;\n prompt?: never;\n /**\n * Same-stage re-entry: the skill is already active in the card's live session,\n * so deliver a compact continuation that references it by name and carries only\n * the fresh arguments, instead of re-pasting the whole skill document. Only valid\n * for named-skill decisions — a plain prompt run has no active skill to resume.\n */\n resume?: boolean;\n }\n | { prompt: string; skillName?: never; resume?: never }\n );\n\nexport interface FactorySendMessageDecision extends FactoryCommitDecisionBase {\n type: 'sendMessage';\n /** Omitted: the card's live session, whichever seat holds it. Required with `prepareBinding`. */\n role?: string;\n message: string;\n priority?: 'medium' | 'high' | 'urgent';\n idleBehavior?: 'persist' | 'wake';\n prepareBinding?: boolean;\n}\n\nexport interface FactoryNotifyDecision extends FactoryCommitDecisionBase {\n type: 'notify';\n title: string;\n body?: string;\n level?: 'info' | 'warning' | 'error';\n}\n\n/**\n * Dismisses Factory change requests an approval has superseded on a GitHub\n * pull request. Only reviews carrying Factory's `Verdict: request changes`\n * marker from an identity other than the approving one are dismissed.\n */\nexport interface FactoryDismissStaleReviewsDecision extends FactoryCommitDecisionBase {\n type: 'dismissStaleReviews';\n installationId: number;\n repository: string;\n pullRequestNumber: number;\n approvingReviewId: string;\n approvingAuthor: string;\n}\n\nexport type FactoryCommitDecision =\n | FactoryTransitionDecision\n | FactoryRouteEventDecision\n | FactorySignalActivityDecision\n | FactoryDismissStaleReviewsDecision\n | FactoryUpsertLinkedWorkItemDecision\n | FactoryInvokeSkillDecision\n | FactorySendMessageDecision\n | FactoryNotifyDecision;\n\nexport type FactoryRuleDecision = FactoryRuleRejectDecision | FactoryCommitDecision;\n\nexport interface FactoryTransitionResultAccepted {\n status: 'accepted';\n transitionId: string;\n itemId: string;\n revision: number;\n stage: FactoryRuleStage;\n decisions: FactoryCommitDecision[];\n}\n\nexport interface FactoryTransitionResultRejected {\n status: 'rejected';\n transitionId: string;\n itemId: string;\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\nexport type FactoryTransitionResult = FactoryTransitionResultAccepted | FactoryTransitionResultRejected;\n\nexport function factoryRuleSourceForWorkItem(source: WorkItemSource): FactoryRuleSource {\n switch (source) {\n case 'github-issue':\n return 'issue';\n case 'github-pr':\n return 'pullRequest';\n case 'gitlab-issue':\n return 'gitlabIssue';\n case 'gitlab-pr':\n return 'gitlabPullRequest';\n case 'linear-issue':\n return 'linearIssue';\n case 'jira-issue':\n return 'jiraIssue';\n case 'incidentio-follow-up':\n return 'incidentioFollowUp';\n case 'github-dependabot-alert':\n return 'dependabotAlert';\n case 'vanta-vulnerability':\n return 'vantaVulnerability';\n case 'detail-finding':\n return 'detailFinding';\n case 'manual':\n return 'manual';\n }\n}\n"],"mappings":";AAiBA,SAAgB,0BACd,QACA,WACA,KACwB;CACxB,MAAM,CAAC,eAAe,QACpB,WAAW,cACP,CAAC,UAAU,cAAc,IACzB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,cACT,CAAC,UAAU,cAAc,IACzB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,iBACT,CAAC,UAAU,OAAO,IAClB,WAAW,eACT,CAAC,QAAQ,OAAO,IAChB,WAAW,yBACT,CAAC,cAAc,OAAO,IACtB,WAAW,4BACT,CAAC,UAAU,kBAAkB,IAC7B,WAAW,wBACT,CAAC,SAAS,eAAe,IACzB,WAAW,mBACT,CAAC,UAAU,SAAS,IACpB,CAAC,WAAW,QAAQ;CAC5C,OAAO;EAAE;EAAe;EAAM,YAAY;EAAW,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CAAG;AAC/E;;AAGA,MAAa,uBAAuB;;AAGpC,MAAa,0BAA0B;AACvC,MAAa,qBAAqB;AAKlC,SAAgB,cACd,MACA,kBACS;CACT,MAAM,SAAS,KAAK,SAAS;CAC7B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO;CACnC,OACE,OAAO,MAAK,UAAS,OAAO,UAAU,YAAY,MAAM,YAAY,MAAA,wBAA0B,MAC7F,KAAK,UAAU,CAAC,EAAA,CAAG,MAAM,gBAAgB;AAE9C;AAEA,SAAgB,eAAe,QAAuD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B,CAAC,iBAAiB,aAAa;AAGpE,MAAa,sBAAsB,CAAC,iBAAiB,aAAa;AAGlE,MAAa,4BAA4B,CAAC,oBAAoB,gBAAgB;AAG9E,MAAa,4BAA4B,CAAC,iBAAiB,aAAa;AAExE,MAAa,uBAAuB,CAAC,yBAAyB,qBAAqB;AAurBnF,SAAgB,6BAA6B,QAA2C;CACtF,QAAQ,QAAR;EACE,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,wBACH,OAAO;EACT,KAAK,2BACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,UACH,OAAO;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/rules/types.ts"],"sourcesContent":["import type { ActivityEvent, BoardEventFacts } from '../boards/board-events.js';\nimport type { ExternalWorkItemSource } from '../storage/domains/work-items/base.js';\nimport type { WorkItemRow } from '../storage/domains/work-items/work-item-schema.js';\n\nexport type WorkItemSource =\n | 'github-issue'\n | 'github-pr'\n | 'gitlab-issue'\n | 'gitlab-pr'\n | 'linear-issue'\n | 'jira-issue'\n | 'incidentio-follow-up'\n | 'github-dependabot-alert'\n | 'vanta-vulnerability'\n | 'detail-finding'\n | 'manual';\n\nexport function externalSourceForWorkItem(\n source: WorkItemSource,\n sourceKey: string,\n url?: string,\n): ExternalWorkItemSource {\n const [integrationId, type] =\n source === 'github-pr'\n ? ['github', 'pull-request']\n : source === 'github-issue'\n ? ['github', 'issue']\n : source === 'gitlab-pr'\n ? ['gitlab', 'pull-request']\n : source === 'gitlab-issue'\n ? ['gitlab', 'issue']\n : source === 'linear-issue'\n ? ['linear', 'issue']\n : source === 'jira-issue'\n ? ['jira', 'issue']\n : source === 'incidentio-follow-up'\n ? ['incidentio', 'issue']\n : source === 'github-dependabot-alert'\n ? ['github', 'dependabot-alert']\n : source === 'vanta-vulnerability'\n ? ['vanta', 'vulnerability']\n : source === 'detail-finding'\n ? ['detail', 'finding']\n : ['factory', 'manual'];\n return { integrationId, type, externalId: sourceKey, ...(url ? { url } : {}) };\n}\n\n/** The source label that holds an issue at rest until a maintainer decides; compared lowercased. */\nexport const NEEDS_APPROVAL_LABEL = 'status: needs approval';\n\n/** Request-changes rounds from self-review before the card parks in Intake for a person. */\nexport const SELF_REVIEW_ROUND_LIMIT = 3;\nexport const AUTO_TRIAGED_LABEL = 'status: auto-triaged';\n\n// The label only holds a card nobody accepted yet (`awaitsAcceptance`, see the boards'\n// `awaitsAcceptance`): once a person moves it into a working lane, the label is stale until the\n// source catches up (Factory removes it on that move).\nexport function needsApproval(\n item: { workItem: Pick<WorkItemRow, 'labels'>; stages?: readonly string[] },\n awaitsAcceptance: (stage: string) => boolean,\n): boolean {\n const labels = item.workItem.labels;\n if (!Array.isArray(labels)) return false;\n return (\n labels.some(label => typeof label === 'string' && label.toLowerCase() === NEEDS_APPROVAL_LABEL) &&\n (item.stages ?? []).every(awaitsAcceptance)\n );\n}\n\nexport function workItemSource(source: ExternalWorkItemSource | null): WorkItemSource {\n if (!source) return 'manual';\n if (source.integrationId === 'linear') return 'linear-issue';\n if (source.integrationId === 'gitlab') return source.type === 'pull-request' ? 'gitlab-pr' : 'gitlab-issue';\n if (source.integrationId === 'jira') return 'jira-issue';\n if (source.integrationId === 'incidentio') return 'incidentio-follow-up';\n if (source.integrationId === 'vanta') return 'vanta-vulnerability';\n if (source.integrationId === 'detail') return 'detail-finding';\n // Only GitHub, GitLab, Linear, Jira, and incident.io have provider-specific\n // rules; anything else (a Slack thread, say) is a plain work item, not a\n // mislabeled GitHub issue.\n if (source.integrationId !== 'github') return 'manual';\n if (source.type === 'dependabot-alert') return 'github-dependabot-alert';\n return source.type === 'pull-request' ? 'github-pr' : 'github-issue';\n}\n\n/** The card's author is inside the write-access circle, or the card is Factory's own PR. */\nexport function authorTrusted(metadata: Record<string, unknown> | null | undefined): boolean {\n return metadata?.authorTrusted === true || metadata?.factoryAuthored === true;\n}\n\n// Authored outside the write-access circle: a missing trust stamp fails closed until\n// the reconcile sweep backfills it, and Factory's own PRs pass through `factoryAuthored`.\nexport function externallyAuthored(item: { source: string; metadata: Record<string, unknown> | null }): boolean {\n if (!['github-pr', 'github-issue', 'gitlab-pr', 'gitlab-issue'].includes(item.source)) return false;\n return !authorTrusted(item.metadata);\n}\n\nexport function externallyAuthoredWorkItem(item: {\n externalSource: ExternalWorkItemSource | null;\n metadata: Record<string, unknown> | null;\n}): boolean {\n return externallyAuthored({ source: workItemSource(item.externalSource), metadata: item.metadata });\n}\n\n/** A phase key on the card's board. Boards name their own phases; Factory reads none of them by name. */\nexport type FactoryRuleStage = string;\n\nexport const FACTORY_TRIAGE_TYPES = [\n 'bug',\n 'feature request',\n 'docs',\n 'question/support',\n 'maintenance',\n 'duplicate',\n 'resolved',\n 'invalid',\n 'spam',\n 'out-of-scope',\n 'other',\n] as const;\nexport type FactoryTriageType = (typeof FACTORY_TRIAGE_TYPES)[number];\n\nexport function isFactoryTriageType(value: unknown): value is FactoryTriageType {\n return typeof value === 'string' && FACTORY_TRIAGE_TYPES.some(type => type === value);\n}\n\n/** A board id. */\nexport type FactoryRuleBoard = string;\n\nexport const FACTORY_RULE_SOURCES = [\n 'issue',\n 'pullRequest',\n 'gitlabIssue',\n 'gitlabPullRequest',\n 'linearIssue',\n 'jiraIssue',\n 'incidentioFollowUp',\n 'dependabotAlert',\n 'vantaVulnerability',\n 'detailFinding',\n 'manual',\n] as const;\nexport type FactoryRuleSource = (typeof FACTORY_RULE_SOURCES)[number];\n\nexport const FACTORY_GITHUB_EVENTS = [\n 'issueOpened',\n 'issueEdited',\n 'issueClosed',\n 'issueReopened',\n 'issueCommentCreated',\n 'issueCommentEdited',\n 'issueCommentDeleted',\n 'pullRequestOpened',\n 'pullRequestUpdated',\n 'pullRequestCommentCreated',\n 'pullRequestReviewRequested',\n 'pullRequestReviewSubmitted',\n 'pullRequestMerged',\n 'pullRequestClosed',\n 'pullRequestReopened',\n] as const;\nexport type FactoryGithubEventName = (typeof FACTORY_GITHUB_EVENTS)[number];\n\nexport const FACTORY_GITLAB_EVENTS = [\n 'issueOpened',\n 'issueUpdated',\n 'issueClosed',\n 'issueReopened',\n 'issueCommented',\n 'mergeRequestOpened',\n 'mergeRequestUpdated',\n 'mergeRequestCommented',\n 'mergeRequestMerged',\n 'mergeRequestClosed',\n] as const;\nexport type FactoryGitLabEventName = (typeof FACTORY_GITLAB_EVENTS)[number];\n\nexport const FACTORY_LINEAR_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryLinearEventName = (typeof FACTORY_LINEAR_EVENTS)[number];\n\nexport const FACTORY_JIRA_EVENTS = ['issueObserved', 'issueClosed'] as const;\nexport type FactoryJiraEventName = (typeof FACTORY_JIRA_EVENTS)[number];\n\nexport const FACTORY_INCIDENTIO_EVENTS = ['followUpObserved', 'followUpClosed'] as const;\nexport type FactoryIncidentioEventName = (typeof FACTORY_INCIDENTIO_EVENTS)[number];\n\nexport const FACTORY_DEPENDABOT_EVENTS = ['alertObserved', 'alertClosed'] as const;\nexport type FactoryDependabotEventName = (typeof FACTORY_DEPENDABOT_EVENTS)[number];\nexport const FACTORY_VANTA_EVENTS = ['vulnerabilityObserved', 'vulnerabilityClosed'] as const;\nexport type FactoryVantaEventName = (typeof FACTORY_VANTA_EVENTS)[number];\n\nexport type FactoryRuleJsonValue =\n | null\n | boolean\n | number\n | string\n | FactoryRuleJsonValue[]\n | { [key: string]: FactoryRuleJsonValue };\n\nexport interface FactoryRuleItemContext {\n workItem: WorkItemRow;\n id: string;\n source: WorkItemSource;\n sourceKey: string | null;\n parentWorkItemId: string | null;\n title: string;\n url: string | null;\n stages: readonly string[];\n /**\n * @deprecated Factory no longer records triage acceptance; this is the value stamped on older\n * cards, and `null` for every card since. A person moving the card on is the approval.\n */\n acceptedAt: Date | null;\n /** Factory-owned process state and trust stamps. */\n metadata: Record<string, unknown> | null;\n}\n\nexport type FactoryRuleActor =\n | { type: 'human'; id: string }\n | { type: 'agent'; bindingId: string; role: string }\n | {\n type: 'github';\n login: string;\n trusted: boolean;\n factoryAuthored: boolean;\n /**\n * Whether GitHub typed the sender as a person (`User`), not an app or bot.\n * Absent on events Factory synthesizes itself and on actors recorded before\n * it existed: neither says a person sent them.\n */\n human?: boolean;\n }\n | { type: 'gitlab'; username: string; trusted: boolean; factoryAuthored: boolean }\n | { type: 'system'; id: string };\n\nexport interface FactoryRuleIngressIdentity {\n type: 'human' | 'agent' | 'toolResult' | 'github' | 'gitlab' | 'linear' | 'jira' | 'incidentio' | 'vanta' | 'rule';\n id: string;\n}\n\nexport interface FactoryRuleCausalEntry {\n ingressId: string;\n decisionType: FactoryCommitDecision['type'];\n}\n\n/** The phase a card sits in, as its board declares it. */\nexport interface FactoryRulePhaseContext {\n id: string;\n kind: 'resting' | 'working' | 'terminal';\n /** Session context a working phase runs in; absent for resting and terminal phases. */\n context?: string;\n /** @deprecated Use `context`. */\n role?: string;\n /** Phases the card may move to from here. */\n nextPhases: readonly string[];\n}\n\nexport interface FactoryRuleContextBase {\n tenant: { orgId: string; projectId: string };\n actor: FactoryRuleActor;\n ingress: FactoryRuleIngressIdentity;\n cause: string;\n causalChain: readonly FactoryRuleCausalEntry[];\n configVersion: string;\n}\n\nexport interface FactoryBoundRuleContext extends FactoryRuleContextBase {\n item: FactoryRuleItemContext;\n board: FactoryRuleBoard;\n itemRevision: number;\n}\n\nexport interface FactoryStageRuleContext extends FactoryBoundRuleContext {\n source: FactoryRuleSource;\n stage: FactoryRuleStage;\n fromStage: FactoryRuleStage;\n toStage: FactoryRuleStage;\n}\n\nexport interface FactoryToolResultRuleContext extends FactoryBoundRuleContext {\n toolName: string;\n threadId: string;\n assistantMessageId: string;\n toolCallId: string;\n result: {\n status: 'success' | 'error';\n value: FactoryRuleJsonValue;\n };\n}\n\nexport interface FactoryGithubRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n /**\n * Set on the one evaluation per pull request delivery that files the pull\n * request's own Review card. Opening a pull request concerns two cards — that\n * Review card and the Work item that authored the pull request — so the rule\n * answers for the two separately: the arrival carries this flag and is\n * committed against the authoring item when resolution found one, which is\n * what links the new card to it, while the authoring item's own evaluation\n * leaves the flag unset.\n */\n pullRequestIntake?: boolean;\n /**\n * Set on both evaluations of a pull request's first sighting when it belongs on an existing\n * card: the Work card that authored it (`authored`), or the card of the issue a trusted author's\n * pull request says it closes (`closes`). The pull request is filed on that card as one more\n * source rather than on a card of its own.\n */\n pullRequestHome?: FactoryPullRequestHome;\n event: FactoryGithubEventName;\n deliveryId: string;\n factory: { createdAt: string };\n /** `installationId` is the GitHub App installation the delivery arrived through. */\n repository: { id: number; fullName: string; installationId?: number };\n issue?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n state?: 'open' | 'closed';\n author?: string;\n /** GitHub close reason: `completed`, `not_planned`, or `duplicate`. */\n stateReason?: string;\n };\n issueChange?: { title: boolean; body: boolean };\n issueComment?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n authorType?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n pullRequest?: {\n number: number;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n requestedReviewers?: string[];\n labels?: string[];\n author?: string;\n factoryAuthored: boolean;\n headBranch: string;\n /** Lowercase head commit SHA, when the delivery carries one. */\n headSha?: string;\n baseBranch: string;\n };\n /** Present on `pullRequestReviewRequested`: who review was (re-)requested from. */\n reviewRequest?: { reviewer: string; factoryReviewer: boolean };\n /** Present when a PR comment uses Factory's exact review command. */\n reviewCommand?: { command: 'review' | 're-review'; target: string };\n /**\n * Present on `pullRequestReviewSubmitted`: the review that was just posted, or a\n * request-changes review whose body was edited to a new Factory verdict.\n */\n review?: { id: number; state: string; url: string; author?: string; body?: string };\n}\n\n/**\n * Where an integration files a new card: the default board's initial phase. The project's intake\n * routes then decide where the card goes; the board and phase a rule names don't. Absent when the\n * default board is not installed.\n */\nexport interface FactoryRuleIntakeTarget {\n board: string;\n initialPhase: string;\n}\n\n/**\n * Where a source-closed rule moves the card, from the `sourceClosed` mapping its installed board\n * declares. Absent when the card's board is not installed or declares no mapping.\n */\nexport interface FactoryRuleBoardClosure {\n /** Title of the card's board, for messages. */\n boardTitle: string;\n /** Terminal phase for a source that was completed. */\n completed: FactoryRuleBoardClosurePhase;\n /** Terminal phase for a source that was canceled or not planned. */\n canceled: FactoryRuleBoardClosurePhase;\n /** Whether the card already sits in a terminal phase of its board. */\n itemTerminal: boolean;\n}\n\nexport interface FactoryRuleBoardClosurePhase {\n phase: string;\n title: string;\n}\n\n/**\n * The phases a card's board runs its pull request loop through, read from what each phase declares\n * (see `boardFlow`). Every field is absent when the board has no such phase.\n */\nexport interface FactoryRuleBoardFlow {\n /** Where a card on the board rests before work starts and goes back to when its pull request is abandoned. */\n readonly initialPhase?: string;\n /** Phase that takes pull requests: reviews them, records verdicts on them, and re-reviews pushes. */\n readonly pullRequestReview?: string;\n /** Working phase that sorts new cards before anyone accepts them: on a board that builds, the first one that neither builds nor reviews. */\n readonly triage?: string;\n /** Working phase that reviews the builder's branch before a pull request opens. */\n readonly selfReview?: string;\n /** Working phase that builds the change and opens the pull request. */\n readonly build?: string;\n /** Seat that runs {@link build}; pull request feedback wakes it. */\n readonly buildRole?: string;\n /** Terminal phase a merge finishes the card in: the board's `sourceClosed.completed`, else its first terminal phase. */\n readonly completed?: Readonly<FactoryRuleBoardClosurePhase>;\n /** Terminal phase a pull request closed unmerged ends its own card in: `sourceClosed.canceled`, else the next terminal phase. */\n readonly canceled?: Readonly<FactoryRuleBoardClosurePhase>;\n}\n\nexport interface FactoryGitLabRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n /** Set on a merge request's first sighting when it is filed on an existing card instead of its own. */\n pullRequestHome?: FactoryPullRequestHome;\n event: FactoryGitLabEventName;\n deliveryId: string;\n factory: { createdAt: string };\n repository: { id: number; fullName: string; host: string };\n issue?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n updatedAt?: string;\n assignees?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n state?: 'open' | 'closed';\n author?: string;\n authorTrusted: boolean;\n };\n note?: {\n id: number;\n body?: string;\n url?: string;\n author?: string;\n createdAt?: string;\n updatedAt?: string;\n };\n mergeRequest?: {\n number: number;\n sourceKey: string;\n title: string;\n url: string;\n createdAt?: string;\n state: 'open' | 'closed';\n draft: boolean;\n merged: boolean;\n assignees?: string[];\n reviewers?: string[];\n labels?: string[];\n labelColors?: Record<string, string>;\n author?: string;\n authorTrusted: boolean;\n factoryAuthored: boolean;\n headBranch: string;\n baseBranch: string;\n };\n}\n\nexport interface FactoryLinearRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryLinearEventName;\n issue: {\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n creator: string | null;\n team: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n sourceId?: string | null;\n projectId?: string | null;\n };\n}\n\nexport interface FactoryJiraRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryJiraEventName;\n issue: {\n /** Stable issue reference — the direct integration's Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n project: string | null;\n site: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryIncidentioRuleContext extends FactoryRuleContextBase {\n /** The status change this delivery reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** The phases the card's board runs its pull request loop through; absent without a card. */\n flow?: FactoryRuleBoardFlow;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryIncidentioEventName;\n issue: {\n /** Stable item reference — the prefixed incident.io follow-up id the intake feed serves as `id`. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n author: string | null;\n /** Reference of the incident this follow-up belongs to, when available. */\n incident: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryDependabotRuleContext extends FactoryRuleContextBase {\n /** The status change this sync reports, named the same for every provider; absent for other events. */\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n /** Where the card's board sends it when its tracked source closes. */\n boardClosure?: FactoryRuleBoardClosure;\n /** What the card's current phase means on its board; absent without a card or when the board does not declare the phase. */\n phase?: FactoryRulePhaseContext;\n /** Where a new card is filed before the project's intake routes place it. */\n intake?: FactoryRuleIntakeTarget;\n event: FactoryDependabotEventName;\n alert: {\n /** Stable alert reference — `owner/repo#dependabot-<number>`. */\n id: string;\n number: number;\n repository: string;\n title: string;\n url: string;\n /** `open`, `dismissed`, `fixed`, or `auto_dismissed`. */\n state: string;\n severity: string | null;\n packageName: string | null;\n ecosystem: string | null;\n manifestPath: string | null;\n /** Markdown writeup for the card's description. */\n description: string | null;\n ghsaId: string | null;\n cveId: string | null;\n labels: readonly string[];\n createdAt: string;\n updatedAt: string;\n };\n}\n\nexport interface FactoryVantaRuleContext extends FactoryRuleContextBase {\n boardEvent?: BoardEventFacts;\n item?: FactoryRuleItemContext;\n board?: FactoryRuleBoard;\n itemRevision?: number;\n boardClosure?: FactoryRuleBoardClosure;\n phase?: FactoryRulePhaseContext;\n intake?: FactoryRuleIntakeTarget;\n event: FactoryVantaEventName;\n vulnerability: {\n /** Vanta vulnerability id — one card per vulnerability, not per advisory. */\n id: string;\n /** Advisory name, e.g. `CVE-2026-118764` or `AIKIDO-2026-54683`. */\n name: string;\n title: string;\n description: string | null;\n url: string | null;\n /** `open`, or `resolved` once Vanta no longer lists it as active. */\n state: 'open' | 'resolved';\n severity: string | null;\n packageIdentifier: string | null;\n fixable: boolean | null;\n remediateBy: string | null;\n labels: readonly string[];\n createdAt: string;\n };\n}\n\nexport type FactoryRuleHandler<TContext> = (\n context: Readonly<TContext>,\n) => FactoryRuleDecision | void | Promise<FactoryRuleDecision | void>;\n\nexport type FactoryRuleRejectionCode =\n | 'forbidden'\n | 'invalid_transition'\n | 'missing_binding'\n | 'stale'\n | 'timeout'\n | 'rule_error'\n | 'causal_depth_exceeded'\n | 'repeated_transition'\n | 'approval_required'\n /** A person moved a card into a phase that may start a run while a run is in flight on it or queued for it. */\n | 'card_busy';\n\nexport interface FactoryRuleRejectDecision {\n type: 'reject';\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\ninterface FactoryCommitDecisionBase {\n idempotencyKey: string;\n}\n\nexport interface FactoryTransitionDecision extends FactoryCommitDecisionBase {\n type: 'transition';\n board: FactoryRuleBoard;\n stage: FactoryRuleStage;\n /**\n * Delivered to the item's active session (waking it if idle) after the\n * transition commits. Skipped when the item has no active run binding, so\n * informational messages never fail the transition.\n */\n message?: { text: string; role?: string };\n /**\n * Runs the stage's entry rules even when the item is already in that stage.\n * A transition to the current stage is normally inert, because most callers\n * are correcting a board into a state it already holds. Re-entry is for the\n * opposite case: the stage's work is in flight and has been invalidated, so\n * it has to start over.\n */\n reenter?: boolean;\n /**\n * The status event this move answers. The project's intake routes on the card's board then\n * decide where the card goes instead, and this move applies only when no route on the board\n * handles the event; a route that does, even a disabled one, owns it. Factory drops the tag\n * from a decision returned by an explicit override on the integration's `rules`, so that\n * override's move always applies; a board handler's tagged move still goes to the routes.\n */\n event?: BoardEventFacts;\n}\n\n/**\n * Hands a status event on an existing card to the project's intake routes: the first enabled\n * route on the card's board whose `on` names the event and whose `when` matches moves the card.\n * Integrations add it when no rule decided anything for the delivery; nothing moves when no\n * route matches.\n */\nexport interface FactoryRouteEventDecision extends FactoryCommitDecisionBase {\n type: 'routeEvent';\n event: BoardEventFacts;\n /**\n * An update the card's own session made (its labels or assignees, set through Factory): held\n * until the session's run ends, then combined with the session's other updates into one event.\n */\n fromCardSession?: true;\n}\n\n/**\n * Tells the card's live session that its source saw activity, such as a new\n * comment or an edit. It carries pointers only: the dispatcher writes the\n * message from these fields, so no provider text (a comment body, a title)\n * ever reaches the session through it. Without a live session it is dropped.\n */\nexport interface FactorySignalActivityDecision extends FactoryCommitDecisionBase {\n type: 'signalActivity';\n event: ActivityEvent;\n /** The source's own reference, such as `acme/app#12`. */\n reference: string;\n url: string;\n author?: string;\n authorTrusted: boolean;\n /**\n * What an idle session does with it. Defaults to `wake`; `persist` leaves it\n * in the session's notifications without starting a run, for sources whose\n * own comments Factory cannot tell apart from other people's. Activity from an\n * untrusted author always persists.\n */\n idleBehavior?: 'wake' | 'persist';\n}\n\n/** The existing card a pull or merge request is filed on; see `pullRequestHome`. */\nexport interface FactoryPullRequestHome {\n workItemId: string;\n reason: 'authored' | 'closes';\n}\n\nexport interface FactoryUpsertLinkedWorkItemDecision extends FactoryCommitDecisionBase {\n type: 'upsertLinkedWorkItem';\n board: FactoryRuleBoard;\n source: WorkItemSource;\n sourceKey: string;\n title: string;\n /** The new card's own description. Only seeds a card being created; an existing card's is left alone. */\n description?: string;\n url: string | null;\n stage: FactoryRuleStage;\n /**\n * File the card at `stage` as its first entry and run none of the board's\n * phase rules for it — no arrival, no destination entry. The card is filed\n * (or, if it already exists, moved) and left parked for a person; nothing is\n * started for it. For external records that arrive already past the board's\n * first step: a GitHub issue whose triage is already recorded, for instance.\n *\n * Placement is the whole decision. An existing card it reaches is moved to\n * that stage through the same relocation the label routes use, and its\n * metadata is left alone.\n */\n skipRules?: boolean;\n /**\n * File the pull or merge request on this existing card, the one that authored it, as one more\n * source instead of on a card of its own. Applies only when no card holds the record yet and\n * the card is still open on Work; otherwise the record is filed as usual.\n */\n attachTo?: { workItemId: string };\n /**\n * The card of the issue this pull or merge request closes. When no card holds the record yet and\n * that card is unfinished, the record links to it, whoever authored it, and the card gets a\n * `pull_request.opened` for its board's card-move rules; otherwise it is filed as usual.\n */\n closesIssue?: { workItemId: string };\n metadata?: Record<string, FactoryRuleJsonValue>;\n}\n\ninterface FactoryInvokeSkillDecisionBase extends FactoryCommitDecisionBase {\n type: 'invokeSkill';\n role: string;\n arguments?: string;\n precedingMessage?: string;\n cancelInFlight?: boolean;\n /**\n * Start this run even when the card was moved by the agent already running in\n * this role's session. The prompt is queued onto that agent's run, so a phase\n * that shares its context with the one before it still gets its own work.\n * Without it, an agent's own move into a phase of its role starts nothing.\n */\n startsAfterOwnMove?: boolean;\n /**\n * Pursue the run's work as a goal: the session's thread holds `objective` until the card\n * leaves the phase, and the agent's goal judge keeps the run going until it is met.\n */\n goal?: { objective: string; maxRuns?: number };\n}\n\n/**\n * Starting an agent run. Most runs activate a skill, because the skill carries\n * the handoff contract later rules match on. A run whose completion is already\n * signalled some other way — Building finishes by opening a pull request, which\n * arrives as its own event — needs no contract, so it can carry a plain prompt\n * instead of an otherwise empty skill.\n */\nexport type FactoryInvokeSkillDecision = FactoryInvokeSkillDecisionBase &\n (\n | {\n skillName: string;\n prompt?: never;\n /**\n * Same-stage re-entry: the skill is already active in the card's live session,\n * so deliver a compact continuation that references it by name and carries only\n * the fresh arguments, instead of re-pasting the whole skill document. Only valid\n * for named-skill decisions — a plain prompt run has no active skill to resume.\n */\n resume?: boolean;\n }\n | { prompt: string; skillName?: never; resume?: never }\n );\n\nexport interface FactorySendMessageDecision extends FactoryCommitDecisionBase {\n type: 'sendMessage';\n /** Omitted: the card's live session, whichever seat holds it. Required with `prepareBinding`. */\n role?: string;\n message: string;\n priority?: 'medium' | 'high' | 'urgent';\n idleBehavior?: 'persist' | 'wake';\n prepareBinding?: boolean;\n}\n\nexport interface FactoryNotifyDecision extends FactoryCommitDecisionBase {\n type: 'notify';\n title: string;\n body?: string;\n level?: 'info' | 'warning' | 'error';\n}\n\n/**\n * Dismisses Factory change requests an approval has superseded on a GitHub\n * pull request. Only reviews carrying Factory's `Verdict: request changes`\n * marker from an identity other than the approving one are dismissed.\n */\nexport interface FactoryDismissStaleReviewsDecision extends FactoryCommitDecisionBase {\n type: 'dismissStaleReviews';\n installationId: number;\n repository: string;\n pullRequestNumber: number;\n approvingReviewId: string;\n approvingAuthor: string;\n}\n\nexport type FactoryCommitDecision =\n | FactoryTransitionDecision\n | FactoryRouteEventDecision\n | FactorySignalActivityDecision\n | FactoryDismissStaleReviewsDecision\n | FactoryUpsertLinkedWorkItemDecision\n | FactoryInvokeSkillDecision\n | FactorySendMessageDecision\n | FactoryNotifyDecision;\n\nexport type FactoryRuleDecision = FactoryRuleRejectDecision | FactoryCommitDecision;\n\nexport interface FactoryTransitionResultAccepted {\n status: 'accepted';\n transitionId: string;\n itemId: string;\n revision: number;\n stage: FactoryRuleStage;\n decisions: FactoryCommitDecision[];\n}\n\nexport interface FactoryTransitionResultRejected {\n status: 'rejected';\n transitionId: string;\n itemId: string;\n code: FactoryRuleRejectionCode;\n reason: string;\n}\n\nexport type FactoryTransitionResult = FactoryTransitionResultAccepted | FactoryTransitionResultRejected;\n\nexport function factoryRuleSourceForWorkItem(source: WorkItemSource): FactoryRuleSource {\n switch (source) {\n case 'github-issue':\n return 'issue';\n case 'github-pr':\n return 'pullRequest';\n case 'gitlab-issue':\n return 'gitlabIssue';\n case 'gitlab-pr':\n return 'gitlabPullRequest';\n case 'linear-issue':\n return 'linearIssue';\n case 'jira-issue':\n return 'jiraIssue';\n case 'incidentio-follow-up':\n return 'incidentioFollowUp';\n case 'github-dependabot-alert':\n return 'dependabotAlert';\n case 'vanta-vulnerability':\n return 'v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