@mastra/factory 0.28.0-alpha.0 → 0.28.0-alpha.10
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 +528 -161
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +12 -6
- package/dist/auth.js.map +1 -1
- package/dist/boards/board-events.d.ts +54 -0
- package/dist/boards/board-events.d.ts.map +1 -0
- package/dist/boards/board-events.js +87 -0
- package/dist/boards/board-events.js.map +1 -0
- package/dist/boards/board-writes.d.ts +86 -0
- package/dist/boards/board-writes.d.ts.map +1 -0
- package/dist/boards/board-writes.js +266 -0
- package/dist/boards/board-writes.js.map +1 -0
- package/dist/boards/card-facts.d.ts +3 -1
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +30 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/default-board.d.ts +7 -0
- package/dist/boards/default-board.d.ts.map +1 -0
- package/dist/boards/default-board.js +10 -0
- package/dist/boards/default-board.js.map +1 -0
- package/dist/boards/define-board.d.ts +56 -23
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +89 -45
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.d.ts +6 -9
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +6 -20
- package/dist/boards/intake-routing.d.ts +55 -11
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +109 -19
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/legacy-plan-role.d.ts.map +1 -1
- package/dist/boards/legacy-plan-role.js +14 -5
- package/dist/boards/legacy-plan-role.js.map +1 -1
- package/dist/boards/phase-automation.d.ts +7 -0
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js +19 -3
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/phase-runner.d.ts +18 -10
- package/dist/boards/phase-runner.d.ts.map +1 -1
- package/dist/boards/phase-runner.js +39 -34
- package/dist/boards/phase-runner.js.map +1 -1
- package/dist/boards/project-boards.d.ts +65 -8
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +217 -26
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts +7 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +19 -4
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/relocate.d.ts +1 -1
- package/dist/boards/relocate.d.ts.map +1 -1
- package/dist/boards/relocate.js +3 -2
- package/dist/boards/relocate.js.map +1 -1
- package/dist/boards/review.d.ts +5 -2
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +12 -11
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +160 -20
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +255 -23
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/stored-board.d.ts +73 -1
- package/dist/boards/stored-board.d.ts.map +1 -1
- package/dist/boards/stored-board.js +157 -11
- package/dist/boards/stored-board.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +43 -0
- package/dist/boards/work-migrations.d.ts.map +1 -0
- package/dist/boards/work-migrations.js +353 -0
- package/dist/boards/work-migrations.js.map +1 -0
- package/dist/boards/work-routes.d.ts +58 -0
- package/dist/boards/work-routes.d.ts.map +1 -0
- package/dist/boards/work-routes.js +270 -0
- package/dist/boards/work-routes.js.map +1 -0
- package/dist/boards/work-seeds.d.ts +9 -0
- package/dist/boards/work-seeds.d.ts.map +1 -0
- package/dist/boards/work-seeds.js +56 -0
- package/dist/boards/work-seeds.js.map +1 -0
- package/dist/boards/work.d.ts +8 -19
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +33 -281
- package/dist/boards/work.js.map +1 -1
- package/dist/environment/build-runner.d.ts.map +1 -1
- package/dist/environment/build-runner.js +2 -2
- package/dist/environment/build-runner.js.map +1 -1
- package/dist/environment/build-workflow.d.ts.map +1 -1
- package/dist/environment/build-workflow.js +6 -5
- package/dist/environment/build-workflow.js.map +1 -1
- package/dist/environment/build.d.ts +15 -2
- package/dist/environment/build.d.ts.map +1 -1
- package/dist/environment/build.js +32 -9
- package/dist/environment/build.js.map +1 -1
- package/dist/factory.d.ts +90 -9
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +334 -141
- package/dist/factory.js.map +1 -1
- package/dist/feed-events.d.ts +4 -4
- package/dist/feed-events.d.ts.map +1 -1
- package/dist/feed-events.js +6 -6
- package/dist/feed-events.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/integrations/base.d.ts +12 -13
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/closing-references.d.ts +15 -0
- package/dist/integrations/closing-references.d.ts.map +1 -0
- package/dist/integrations/closing-references.js +69 -0
- package/dist/integrations/closing-references.js.map +1 -0
- package/dist/integrations/github/acceptance-labels.d.ts +4 -0
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +1 -1
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +17 -75
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +134 -77
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +7 -3
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +21 -3
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/provenance.js +1 -1
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/pull-request-source.d.ts +8 -0
- package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
- package/dist/integrations/github/pull-request-source.js +17 -0
- package/dist/integrations/github/pull-request-source.js.map +1 -0
- package/dist/integrations/github/reconcile-worker.d.ts +5 -1
- package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +39 -6
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/review-status-comment.d.ts +61 -0
- package/dist/integrations/github/review-status-comment.d.ts.map +1 -0
- package/dist/integrations/github/review-status-comment.js +217 -0
- package/dist/integrations/github/review-status-comment.js.map +1 -0
- package/dist/integrations/github/review-status-reporter.d.ts +42 -0
- package/dist/integrations/github/review-status-reporter.d.ts.map +1 -0
- package/dist/integrations/github/review-status-reporter.js +104 -0
- package/dist/integrations/github/review-status-reporter.js.map +1 -0
- package/dist/integrations/github/review-status.d.ts +28 -0
- package/dist/integrations/github/review-status.d.ts.map +1 -0
- package/dist/integrations/github/review-status.js +95 -0
- package/dist/integrations/github/review-status.js.map +1 -0
- package/dist/integrations/github/routes.d.ts +4 -3
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +11 -91
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +92 -8
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +498 -103
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +10 -2
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +20 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +2 -2
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.d.ts +2 -1
- package/dist/integrations/github/token-refresh.d.ts.map +1 -1
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/gitlab/agent-tools.js +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +96 -39
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +109 -46
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +2 -1
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +12 -5
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +2 -6
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +22 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +188 -34
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/incidentio/agent-tools.js +6 -6
- package/dist/integrations/incidentio/agent-tools.js.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts +1 -9
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +6 -7
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +2 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +2 -2
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +11 -17
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +11 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +52 -16
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/issue-reconciler.js +1 -1
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/agent-tools.js +1 -1
- package/dist/integrations/jira/binding-scope.d.ts +5 -6
- package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
- package/dist/integrations/jira/binding-scope.js +9 -11
- package/dist/integrations/jira/binding-scope.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts +1 -9
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +6 -7
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +2 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +4 -9
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +11 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +52 -16
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts +9 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +81 -3
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +1 -9
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +6 -7
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts +4 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +21 -1
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -1
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +2 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +16 -21
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +11 -4
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +50 -17
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +7 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +42 -5
- 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 -0
- package/dist/integrations/platform/connect/session-tools.js +35 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +4 -1
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +39 -3
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +8 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +132 -90
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +4 -9
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +10 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +7 -8
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.d.ts +2 -0
- package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +6 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/slack/chat-tools.js +1 -1
- package/dist/integrations/slack/connect-route.d.ts.map +1 -1
- package/dist/integrations/slack/connect-route.js +1 -1
- package/dist/integrations/slack/connect-route.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts +0 -2
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +2 -5
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/reply-tool.js +1 -1
- package/dist/integrations/slack/run-error-card.js +1 -0
- package/dist/integrations/slack/run-error-card.js.map +1 -1
- package/dist/integrations/slack/share-file-tool.js +1 -1
- package/dist/integrations/slack/slack.d.ts +23 -30
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +131 -125
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/slack/voice-clips.d.ts +32 -0
- package/dist/integrations/slack/voice-clips.d.ts.map +1 -0
- package/dist/integrations/slack/voice-clips.js +201 -0
- package/dist/integrations/slack/voice-clips.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -1
- package/dist/integrations/workos/integration.js +1 -3
- package/dist/integrations/workos/integration.js.map +1 -1
- package/dist/links.d.ts +1 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +4 -4
- package/dist/links.js.map +1 -1
- package/dist/mcp/routes.js +2 -2
- package/dist/mcp/routes.js.map +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/provider-display-name.d.ts.map +1 -1
- package/dist/provider-display-name.js +1 -0
- package/dist/provider-display-name.js.map +1 -1
- package/dist/routes/attention-parked.d.ts +1 -0
- package/dist/routes/attention-parked.d.ts.map +1 -1
- package/dist/routes/attention-parked.js +2 -2
- package/dist/routes/attention-parked.js.map +1 -1
- package/dist/routes/attention-providers.d.ts +0 -25
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +3 -151
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts +0 -2
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +2 -13
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/automation-runs.d.ts +5 -1
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +16 -4
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +15 -0
- package/dist/routes/board-snapshot.d.ts.map +1 -0
- package/dist/routes/board-snapshot.js +41 -0
- package/dist/routes/board-snapshot.js.map +1 -0
- package/dist/routes/boards.d.ts +9 -7
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js +59 -145
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +11 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +122 -29
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +366 -34
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +179 -51
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/feed-events.d.ts +15 -0
- package/dist/routes/feed-events.d.ts.map +1 -0
- package/dist/routes/feed-events.js +68 -0
- package/dist/routes/feed-events.js.map +1 -0
- package/dist/routes/fs.d.ts +4 -0
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +9 -8
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +25 -13
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +0 -23
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +16 -314
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +2 -5
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts +19 -0
- package/dist/routes/mastra-gateway.d.ts.map +1 -0
- package/dist/routes/mastra-gateway.js +120 -0
- package/dist/routes/mastra-gateway.js.map +1 -0
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +1 -4
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +80 -61
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +6 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +44 -3
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +8 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +5 -1
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/running-packages.d.ts +13 -0
- package/dist/routes/running-packages.d.ts.map +1 -0
- package/dist/routes/running-packages.js +45 -0
- package/dist/routes/running-packages.js.map +1 -0
- package/dist/routes/sandbox-envs.d.ts +26 -0
- package/dist/routes/sandbox-envs.d.ts.map +1 -0
- package/dist/routes/sandbox-envs.js +180 -0
- package/dist/routes/sandbox-envs.js.map +1 -0
- package/dist/routes/session-access.d.ts.map +1 -1
- package/dist/routes/session-access.js +12 -3
- package/dist/routes/session-access.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +1 -4
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +1 -3
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/source-control-settings.d.ts.map +1 -1
- package/dist/routes/source-control-settings.js +3 -2
- package/dist/routes/source-control-settings.js.map +1 -1
- package/dist/routes/surface.d.ts +13 -9
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +116 -43
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +5 -1
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/voice.d.ts +48 -0
- package/dist/routes/voice.d.ts.map +1 -0
- package/dist/routes/voice.js +248 -0
- package/dist/routes/voice.js.map +1 -0
- package/dist/routes/work-items.d.ts +0 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +39 -14
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +1 -0
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/dispatcher.d.ts +28 -9
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +734 -143
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +71 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +94 -1
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/index.d.ts +2 -4
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -3
- package/dist/rules/phase-goal.d.ts +54 -0
- package/dist/rules/phase-goal.d.ts.map +1 -0
- package/dist/rules/phase-goal.js +70 -0
- package/dist/rules/phase-goal.js.map +1 -0
- package/dist/rules/phase-tools.d.ts +11 -0
- package/dist/rules/phase-tools.d.ts.map +1 -0
- package/dist/rules/phase-tools.js +19 -0
- package/dist/rules/phase-tools.js.map +1 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +116 -15
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/review-source-tool.d.ts +4 -1
- package/dist/rules/review-source-tool.d.ts.map +1 -1
- package/dist/rules/review-source-tool.js +24 -4
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/rule-group.d.ts +1 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +15 -6
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +5 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +9 -3
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +39 -28
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +10 -7
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +63 -55
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +140 -39
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +7 -41
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +89 -4
- package/dist/rules/validation.js.map +1 -1
- package/dist/run-error.d.ts +1 -1
- package/dist/run-error.d.ts.map +1 -1
- package/dist/run-error.js +38 -5
- package/dist/run-error.js.map +1 -1
- package/dist/sandbox/sandbox-env-cache.d.ts +33 -0
- package/dist/sandbox/sandbox-env-cache.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env-cache.js +140 -0
- package/dist/sandbox/sandbox-env-cache.js.map +1 -0
- package/dist/sandbox/sandbox-env.d.ts +77 -0
- package/dist/sandbox/sandbox-env.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env.js +130 -0
- package/dist/sandbox/sandbox-env.js.map +1 -0
- package/dist/secret-encryption.d.ts +21 -0
- package/dist/secret-encryption.d.ts.map +1 -1
- package/dist/secret-encryption.js +31 -4
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/credential-policy.d.ts +2 -2
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +3 -3
- package/dist/session/credential-policy.js.map +1 -1
- package/dist/session/default-model-hydration.d.ts +2 -2
- package/dist/session/default-model-hydration.d.ts.map +1 -1
- package/dist/session/default-model-hydration.js +4 -4
- package/dist/session/default-model-hydration.js.map +1 -1
- package/dist/session/live-sessions.d.ts +11 -4
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +31 -10
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +6 -4
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +9 -12
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-threads.d.ts +10 -3
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +11 -1
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +39 -13
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +55 -61
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts +24 -0
- package/dist/session/work-item-state-processor.d.ts.map +1 -0
- package/dist/session/work-item-state-processor.js +275 -0
- package/dist/session/work-item-state-processor.js.map +1 -0
- package/dist/skills/catalog.js +1 -1
- package/dist/storage/domains/audit/actions.d.ts +3 -2
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +7 -5
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/domain.d.ts.map +1 -1
- package/dist/storage/domains/audit/domain.js +1 -3
- package/dist/storage/domains/audit/domain.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +107 -23
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +201 -65
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +25 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/channel-identity/base.d.ts +0 -4
- package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
- package/dist/storage/domains/channel-identity/base.js +0 -7
- package/dist/storage/domains/channel-identity/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +5 -45
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +11 -89
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/memory-settings/base.d.ts +0 -8
- package/dist/storage/domains/memory-settings/base.d.ts.map +1 -1
- package/dist/storage/domains/memory-settings/base.js +1 -11
- package/dist/storage/domains/memory-settings/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +23 -9
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +24 -8
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/sandbox-envs/base.d.ts +70 -0
- package/dist/storage/domains/sandbox-envs/base.d.ts.map +1 -0
- package/dist/storage/domains/sandbox-envs/base.js +227 -0
- package/dist/storage/domains/sandbox-envs/base.js.map +1 -0
- package/dist/storage/domains/voice-settings/base.d.ts +31 -0
- package/dist/storage/domains/voice-settings/base.d.ts.map +1 -0
- package/dist/storage/domains/voice-settings/base.js +81 -0
- package/dist/storage/domains/voice-settings/base.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +93 -24
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +413 -188
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/board-version.d.ts +6 -2
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
- package/dist/storage/domains/work-items/board-version.js +20 -9
- package/dist/storage/domains/work-items/board-version.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +33 -5
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +208 -25
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
- package/dist/storage/domains/work-items/legacy-review.js +109 -0
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +12 -4
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js +14 -32
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +6 -2
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +83 -27
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/timing.d.ts +1 -0
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +1 -1
- package/dist/timing.js.map +1 -1
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +28 -9
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts +3 -0
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +2 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/read-tools.d.ts +10 -6
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +89 -39
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +1 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +2 -1
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +1 -1
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +1 -0
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/sandbox-tools.js +1 -1
- package/dist/tools/session-tools.d.ts +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +1 -1
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.d.ts +3 -1
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +13 -4
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +2 -0
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +2 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +0 -3
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +10 -20
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/voice/rate-limit.d.ts +13 -0
- package/dist/voice/rate-limit.d.ts.map +1 -0
- package/dist/voice/rate-limit.js +36 -0
- package/dist/voice/rate-limit.js.map +1 -0
- package/dist/voice/realtime.d.ts +13 -0
- package/dist/voice/realtime.d.ts.map +1 -0
- package/dist/voice/realtime.js +56 -0
- package/dist/voice/realtime.js.map +1 -0
- package/dist/voice/transcription.d.ts +51 -0
- package/dist/voice/transcription.d.ts.map +1 -0
- package/dist/voice/transcription.js +112 -0
- package/dist/voice/transcription.js.map +1 -0
- package/dist/work-item-branch.d.ts +13 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +16 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts +6 -0
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +28 -3
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/description-context.d.ts +5 -0
- package/dist/work-items/description-context.d.ts.map +1 -0
- package/dist/work-items/description-context.js +17 -0
- package/dist/work-items/description-context.js.map +1 -0
- package/dist/work-items/providers/base.d.ts +4 -1
- package/dist/work-items/providers/base.d.ts.map +1 -1
- package/dist/work-items/providers/base.js +6 -1
- package/dist/work-items/providers/base.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +2 -1
- package/dist/work-items/providers/github.js.map +1 -1
- package/dist/work-items/providers/gitlab.d.ts.map +1 -1
- package/dist/work-items/providers/gitlab.js +2 -1
- package/dist/work-items/providers/gitlab.js.map +1 -1
- package/dist/work-items/providers/jira.d.ts.map +1 -1
- package/dist/work-items/providers/jira.js +3 -2
- package/dist/work-items/providers/jira.js.map +1 -1
- package/dist/work-items/providers/linear.d.ts.map +1 -1
- package/dist/work-items/providers/linear.js +3 -2
- package/dist/work-items/providers/linear.js.map +1 -1
- package/dist/work-items/providers/types.d.ts +6 -0
- package/dist/work-items/providers/types.d.ts.map +1 -1
- package/dist/work-items/split-backfill.d.ts +13 -0
- package/dist/work-items/split-backfill.d.ts.map +1 -0
- package/dist/work-items/split-backfill.js +32 -0
- package/dist/work-items/split-backfill.js.map +1 -0
- package/dist/work-items/split-migration.d.ts +39 -2
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +178 -70
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +3 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +118 -34
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +13 -11
- package/factory-skills/factory-build/SKILL.md +64 -0
- package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
- package/factory-skills/factory-gitlab-review/SKILL.md +6 -6
- package/factory-skills/factory-plan/SKILL.md +8 -10
- package/factory-skills/factory-rereview/SKILL.md +74 -28
- package/factory-skills/factory-review/SKILL.md +85 -29
- package/factory-skills/factory-self-review/SKILL.md +32 -13
- package/factory-skills/factory-triage/SKILL.md +36 -32
- package/package.json +12 -11
- package/dist/boards/index.js.map +0 -1
- package/dist/boards/pull-request-review.d.ts +0 -14
- package/dist/boards/pull-request-review.d.ts.map +0 -1
- package/dist/boards/pull-request-review.js +0 -81
- package/dist/boards/pull-request-review.js.map +0 -1
- package/dist/boards/work-tool-rules.d.ts +0 -8
- package/dist/boards/work-tool-rules.d.ts.map +0 -1
- package/dist/boards/work-tool-rules.js +0 -19
- package/dist/boards/work-tool-rules.js.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +0 -8
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.js +0 -1984
- package/dist/integrations/slack/emoji-shortcodes.generated.js.map +0 -1
- package/dist/integrations/slack/emoji.d.ts +0 -3
- package/dist/integrations/slack/emoji.d.ts.map +0 -1
- package/dist/integrations/slack/emoji.js +0 -11
- package/dist/integrations/slack/emoji.js.map +0 -1
- package/dist/integrations/slack/feed-publisher.d.ts +0 -26
- package/dist/integrations/slack/feed-publisher.d.ts.map +0 -1
- package/dist/integrations/slack/feed-publisher.js +0 -43
- package/dist/integrations/slack/feed-publisher.js.map +0 -1
- package/dist/routes/attention-activity.d.ts +0 -23
- package/dist/routes/attention-activity.d.ts.map +0 -1
- package/dist/routes/attention-activity.js +0 -154
- package/dist/routes/attention-activity.js.map +0 -1
- package/dist/rules/resolve.d.ts +0 -15
- package/dist/rules/resolve.d.ts.map +0 -1
- package/dist/rules/resolve.js +0 -22
- package/dist/rules/resolve.js.map +0 -1
- package/dist/storage/domains/comments/activity.d.ts +0 -40
- package/dist/storage/domains/comments/activity.d.ts.map +0 -1
- package/dist/storage/domains/comments/activity.js +0 -93
- package/dist/storage/domains/comments/activity.js.map +0 -1
- package/dist/storage/domains/comments/actor.d.ts +0 -51
- package/dist/storage/domains/comments/actor.d.ts.map +0 -1
- package/dist/storage/domains/comments/actor.js +0 -37
- package/dist/storage/domains/comments/actor.js.map +0 -1
- package/dist/storage/domains/comments/base.d.ts +0 -245
- package/dist/storage/domains/comments/base.d.ts.map +0 -1
- package/dist/storage/domains/comments/base.js +0 -539
- package/dist/storage/domains/comments/base.js.map +0 -1
- package/dist/storage/domains/comments/domain.d.ts +0 -135
- package/dist/storage/domains/comments/domain.d.ts.map +0 -1
- package/dist/storage/domains/comments/domain.js +0 -284
- package/dist/storage/domains/comments/domain.js.map +0 -1
- package/dist/storage/domains/comments/feed-context.d.ts +0 -22
- package/dist/storage/domains/comments/feed-context.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-context.js +0 -88
- package/dist/storage/domains/comments/feed-context.js.map +0 -1
- package/dist/storage/domains/comments/feed-sync.d.ts +0 -21
- package/dist/storage/domains/comments/feed-sync.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-sync.js +0 -1
- package/dist/storage/domains/comments/parse.d.ts +0 -23
- package/dist/storage/domains/comments/parse.d.ts.map +0 -1
- package/dist/storage/domains/comments/parse.js +0 -89
- package/dist/storage/domains/comments/parse.js.map +0 -1
- package/dist/storage/domains/comments/routes.d.ts +0 -24
- package/dist/storage/domains/comments/routes.d.ts.map +0 -1
- package/dist/storage/domains/comments/routes.js +0 -301
- package/dist/storage/domains/comments/routes.js.map +0 -1
- package/dist/storage/domains/comments/schema.d.ts +0 -5
- package/dist/storage/domains/comments/schema.d.ts.map +0 -1
- package/dist/storage/domains/comments/schema.js +0 -178
- package/dist/storage/domains/comments/schema.js.map +0 -1
- package/dist/storage/domains/comments/wire.d.ts +0 -40
- package/dist/storage/domains/comments/wire.d.ts.map +0 -1
- package/dist/storage/domains/comments/wire.js +0 -36
- package/dist/storage/domains/comments/wire.js.map +0 -1
- package/factory-skills/factory-complete-issue/SKILL.md +0 -24
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { factoryDispatchFailureMetadata } from "../../../rules/dispatch-errors.js";
|
|
2
2
|
import { FACTORY_TRIAGE_TYPES, externalSourceForWorkItem } from "../../../rules/types.js";
|
|
3
3
|
import { workItemProviderAdapter } from "../../../work-items/providers/index.js";
|
|
4
|
-
import { migrateWorkItemSplit } from "../../../work-items/split-migration.js";
|
|
5
|
-
import {
|
|
6
|
-
import { BoardScopes, FACTORY_BOARD_VERSIONS_SCHEMA, bumpBoardVersions, readBoardVersion, trackBoardWrites } from "./board-version.js";
|
|
4
|
+
import { copyLegacyRows, migrateWorkItemSplit, readLegacyWatermark, readWorkItemSplitMarker, recordWorkItemSplitComplete } from "../../../work-items/split-migration.js";
|
|
5
|
+
import { BoardScopes, CARD_TABLES, DECISION_TABLES, FACTORY_BOARD_VERSIONS_SCHEMA, bumpBoardVersions, readBoardVersion, trackBoardWrites } from "./board-version.js";
|
|
7
6
|
import { Cards, splitCardRows } from "./cards.js";
|
|
8
7
|
import { LEASE_TABLES, trackClaimableWrites } from "./claimable-work.js";
|
|
8
|
+
import { LEGACY_REST_PHASE, LEGACY_WORK_BOARD, readReviewBoardInUse } from "./legacy-review.js";
|
|
9
9
|
import { splitCardMetadata } from "../../../work-items/providers/metadata-keys.js";
|
|
10
|
-
import { FACTORY_BOARD_ITEMS_SCHEMA, FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA, FACTORY_WORK_ITEMS_SCHEMA, FACTORY_WORK_ITEM_SOURCES_SCHEMA, FACTORY_WORK_ITEM_SPLIT_LOCKS_SCHEMA, WORK_ITEMS_SCHEMA, primarySource } from "./work-item-schema.js";
|
|
10
|
+
import { FACTORY_BOARD_ITEMS_SCHEMA, FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA, FACTORY_WORK_ITEMS_SCHEMA, FACTORY_WORK_ITEM_SOURCES_SCHEMA, FACTORY_WORK_ITEM_SPLIT_LOCKS_SCHEMA, FACTORY_WORK_ITEM_SPLIT_STATE_SCHEMA, WORK_ITEMS_SCHEMA, primarySource } from "./work-item-schema.js";
|
|
11
11
|
import { createHash } from "crypto";
|
|
12
12
|
import { FactoryStorageDomain, UniqueViolationError } from "@mastra/core/storage";
|
|
13
13
|
// src/storage/domains/work-items/base.ts
|
|
@@ -20,6 +20,14 @@ import { FactoryStorageDomain, UniqueViolationError } from "@mastra/core/storage
|
|
|
20
20
|
* atomically so concurrent actors do not overwrite each other. The authoritative
|
|
21
21
|
* Factory transition path keeps one exclusive current stage per item.
|
|
22
22
|
*/
|
|
23
|
+
/** Freeze `value` and everything reachable from it, so shared cache entries cannot be written to. */
|
|
24
|
+
function deepFreeze(value) {
|
|
25
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
26
|
+
Object.freeze(value);
|
|
27
|
+
for (const entry of Object.values(value)) deepFreeze(entry);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
23
31
|
function stableJson(value) {
|
|
24
32
|
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
25
33
|
if (value && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableJson(entry)}`).join(",")}}`;
|
|
@@ -79,15 +87,6 @@ const STORED_FACTORY_DISPATCH_FAILURE_CODES = [...FACTORY_DISPATCH_FAILURE_CODES
|
|
|
79
87
|
function isStoredFactoryDispatchFailureCode(value) {
|
|
80
88
|
return STORED_FACTORY_DISPATCH_FAILURE_CODES.some((code) => code === value);
|
|
81
89
|
}
|
|
82
|
-
/** Stages in which a bound run can still act on its work item. */
|
|
83
|
-
const ACTIVE_RUN_BINDING_STAGES = /* @__PURE__ */ new Set([
|
|
84
|
-
"intake",
|
|
85
|
-
"triage",
|
|
86
|
-
"planning",
|
|
87
|
-
"execute",
|
|
88
|
-
"review",
|
|
89
|
-
"pr-review"
|
|
90
|
-
]);
|
|
91
90
|
function factoryDecisionAttentionIdentity(decisionId, failureOccurrence) {
|
|
92
91
|
return {
|
|
93
92
|
kind: "automation-failed",
|
|
@@ -112,21 +111,6 @@ function proposalReceiptFilter(orgId, factoryProjectId, decisionId) {
|
|
|
112
111
|
occurrence: identity.occurrence
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
|
-
function factoryMentionAttentionIdentity(commentId) {
|
|
116
|
-
return {
|
|
117
|
-
kind: "mention",
|
|
118
|
-
sourceId: commentId,
|
|
119
|
-
occurrence: 0
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/** Collapsed per work item, so the occurrence is what a new comment bumps. */
|
|
123
|
-
function factoryActivityAttentionIdentity(workItemId, occurrence) {
|
|
124
|
-
return {
|
|
125
|
-
kind: "activity",
|
|
126
|
-
sourceId: workItemId,
|
|
127
|
-
occurrence
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
114
|
/** Dated by the park itself, so an answer and a new park never share a receipt. */
|
|
131
115
|
function factoryAgentWaitingAttentionIdentity(sessionId, suspendedAt) {
|
|
132
116
|
return {
|
|
@@ -246,6 +230,7 @@ function toWorkItem(row) {
|
|
|
246
230
|
externalSource: row.external_source,
|
|
247
231
|
parentWorkItemId: row.parent_work_item_id,
|
|
248
232
|
title: row.title,
|
|
233
|
+
description: row.description ?? null,
|
|
249
234
|
stages: row.stages,
|
|
250
235
|
stageHistory: row.stage_history,
|
|
251
236
|
sessions: row.sessions,
|
|
@@ -253,7 +238,6 @@ function toWorkItem(row) {
|
|
|
253
238
|
triageType: row.triage_type ?? null,
|
|
254
239
|
autonomyArmedAt: row.autonomy_armed_at ?? null,
|
|
255
240
|
acceptedAt: row.accepted_at ?? null,
|
|
256
|
-
commentCount: row.comment_count ?? 0,
|
|
257
241
|
revision: row.revision,
|
|
258
242
|
createdBy: row.created_by,
|
|
259
243
|
createdAt: row.created_at,
|
|
@@ -266,6 +250,7 @@ function patchColumns(changes) {
|
|
|
266
250
|
...changes.board !== void 0 ? { board: changes.board } : {},
|
|
267
251
|
...changes.parentWorkItemId !== void 0 ? { parent_work_item_id: changes.parentWorkItemId } : {},
|
|
268
252
|
...changes.title !== void 0 ? { title: changes.title } : {},
|
|
253
|
+
...changes.description !== void 0 ? { description: changes.description } : {},
|
|
269
254
|
...changes.stages !== void 0 ? { stages: changes.stages } : {},
|
|
270
255
|
...changes.stageHistory !== void 0 ? { stage_history: changes.stageHistory } : {},
|
|
271
256
|
...changes.sessions !== void 0 ? { sessions: changes.sessions } : {},
|
|
@@ -290,6 +275,13 @@ function priorState(row) {
|
|
|
290
275
|
};
|
|
291
276
|
}
|
|
292
277
|
var WorkItemSplitModeError = class extends Error {};
|
|
278
|
+
const OPEN_PASS_PAGE_SIZE = 500;
|
|
279
|
+
function logSplit(line) {
|
|
280
|
+
console.info(`[factory] ${line}`);
|
|
281
|
+
}
|
|
282
|
+
function sameWatermark(a, b) {
|
|
283
|
+
return a !== null && a.id === b.id && new Date(a.updatedAt).getTime() === new Date(b.updatedAt).getTime();
|
|
284
|
+
}
|
|
293
285
|
var WorkItemRelationError = class extends Error {
|
|
294
286
|
code = "invalid_work_item_relation";
|
|
295
287
|
};
|
|
@@ -301,6 +293,15 @@ var WorkItemUpdateConflictError = class extends Error {
|
|
|
301
293
|
this.reason = reason;
|
|
302
294
|
}
|
|
303
295
|
};
|
|
296
|
+
/** The source a caller tried to attach already belongs to another work item in the project. */
|
|
297
|
+
var WorkItemSourceConflictError = class extends Error {
|
|
298
|
+
ownerWorkItemId;
|
|
299
|
+
code = "work_item_source_conflict";
|
|
300
|
+
constructor(ownerWorkItemId) {
|
|
301
|
+
super(`The source already belongs to work item ${ownerWorkItemId}.`);
|
|
302
|
+
this.ownerWorkItemId = ownerWorkItemId;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
304
305
|
function validateParentRelation(projectItems, itemId, parentWorkItemId) {
|
|
305
306
|
if (parentWorkItemId === null) return;
|
|
306
307
|
const byId = new Map(projectItems.map((item) => [item.id, item]));
|
|
@@ -356,6 +357,7 @@ function applyUpdate({ current, userId, input, now = /* @__PURE__ */ new Date()
|
|
|
356
357
|
...input.board !== void 0 ? { board: input.board } : {},
|
|
357
358
|
...input.parentWorkItemId !== void 0 ? { parent_work_item_id: input.parentWorkItemId } : {},
|
|
358
359
|
...input.title !== void 0 ? { title: input.title } : {},
|
|
360
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
359
361
|
...input.stages !== void 0 ? {
|
|
360
362
|
stages: input.stages,
|
|
361
363
|
stage_history: applyStageTransition(current.stage_history, current.stages, input.stages, userId, now)
|
|
@@ -634,18 +636,30 @@ const FACTORY_GOVERNANCE_SCHEMAS = [
|
|
|
634
636
|
nullable: true
|
|
635
637
|
}
|
|
636
638
|
},
|
|
637
|
-
indexes: [
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
639
|
+
indexes: [
|
|
640
|
+
{
|
|
641
|
+
name: "factory_run_bindings_session_idx",
|
|
642
|
+
columns: [
|
|
643
|
+
"factory_project_id",
|
|
644
|
+
"thread_id",
|
|
645
|
+
"resource_id",
|
|
646
|
+
"session_id"
|
|
647
|
+
]
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "factory_run_bindings_org_thread_idx",
|
|
651
|
+
columns: [
|
|
652
|
+
"org_id",
|
|
653
|
+
"thread_id",
|
|
654
|
+
"resource_id",
|
|
655
|
+
"session_id"
|
|
656
|
+
]
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: "factory_run_bindings_status_idx",
|
|
660
|
+
columns: ["status"]
|
|
661
|
+
}
|
|
662
|
+
]
|
|
649
663
|
},
|
|
650
664
|
{
|
|
651
665
|
name: "factory_tool_result_cursors",
|
|
@@ -759,7 +773,7 @@ function toDeferredDecision(row) {
|
|
|
759
773
|
};
|
|
760
774
|
}
|
|
761
775
|
function attentionReceiptKind(value) {
|
|
762
|
-
if (value === "automation-failed" || value === "automation-proposed" || value === "
|
|
776
|
+
if (value === "automation-failed" || value === "automation-proposed" || value === "agent-waiting") return value;
|
|
763
777
|
throw new Error(`Unsupported attention receipt kind '${String(value)}'.`);
|
|
764
778
|
}
|
|
765
779
|
function attentionReceiptState(value) {
|
|
@@ -813,27 +827,61 @@ function toPendingStart(row) {
|
|
|
813
827
|
/** A safety net, not the invalidation path: bounds how long a missed version bump or a stuck read can last. */
|
|
814
828
|
const LIST_CACHE_TTL_MS = 6e4;
|
|
815
829
|
const LIST_CACHE_MAX_PROJECTS = 100;
|
|
830
|
+
const LIST_DELTA_CLOCK_SKEW_MS = 5e3;
|
|
816
831
|
var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
817
832
|
/** Last full card list per project, valid while the project's board version is unchanged. */
|
|
833
|
+
/** `takenAt` is the last full read; `readFrom` when the latest read, full or delta, began. */
|
|
818
834
|
#listCache = /* @__PURE__ */ new Map();
|
|
819
835
|
#listInFlight = /* @__PURE__ */ new Map();
|
|
820
|
-
#
|
|
836
|
+
#boardChanged = () => {};
|
|
821
837
|
#claimableWorkListeners = /* @__PURE__ */ new Set();
|
|
822
838
|
#isTerminal = () => false;
|
|
823
839
|
#legacyMode = false;
|
|
840
|
+
/**
|
|
841
|
+
* Legacy cards this replica may still have to copy. While pending, lookups by id or source
|
|
842
|
+
* copy a missed card on demand; `since` limits the passes to rows written after the last
|
|
843
|
+
* finished pass.
|
|
844
|
+
*/
|
|
845
|
+
#split = {
|
|
846
|
+
pending: false,
|
|
847
|
+
since: null
|
|
848
|
+
};
|
|
824
849
|
get legacyMode() {
|
|
825
850
|
return this.#legacyMode;
|
|
826
851
|
}
|
|
852
|
+
get legacyBackfillPending() {
|
|
853
|
+
return this.#split.pending;
|
|
854
|
+
}
|
|
855
|
+
/** Projects found not to use the Review board; once redundant it stays so, with no card left to reopen on it. */
|
|
856
|
+
#reviewRedundant = /* @__PURE__ */ new Set();
|
|
857
|
+
/** {@link reviewBoardInUse} through `ops`, so a caller inside a transaction reads within it. */
|
|
858
|
+
#reviewInUse = async (ops, scope) => {
|
|
859
|
+
const key = `${scope.orgId}\0${scope.factoryProjectId}`;
|
|
860
|
+
if (this.#reviewRedundant.has(key)) return false;
|
|
861
|
+
const inUse = await readReviewBoardInUse(ops, scope, {
|
|
862
|
+
split: !this.#legacyMode,
|
|
863
|
+
legacy: this.#legacyMode || this.#split.pending
|
|
864
|
+
});
|
|
865
|
+
if (!inUse) this.#reviewRedundant.add(key);
|
|
866
|
+
return inUse;
|
|
867
|
+
};
|
|
868
|
+
/**
|
|
869
|
+
* Whether the project still uses the retired Review board: it holds a card stored on Review
|
|
870
|
+
* that isn't Done or Canceled. Such a project keeps the board and its cards stay on it; in any
|
|
871
|
+
* other project Review is redundant and its cards read as Work.
|
|
872
|
+
*/
|
|
873
|
+
reviewBoardInUse(scope) {
|
|
874
|
+
return this.#reviewInUse(this.#db, scope);
|
|
875
|
+
}
|
|
827
876
|
constructor() {
|
|
828
877
|
super("work-items");
|
|
829
878
|
}
|
|
830
879
|
/**
|
|
831
|
-
* Wired once at boot.
|
|
832
|
-
*
|
|
833
|
-
* has to remember, since clients stop polling while their stream is up.
|
|
880
|
+
* Wired once at boot. Fires after a committed write changes what a board shows of a card
|
|
881
|
+
* or a deferred decision, so open boards refetch instead of polling.
|
|
834
882
|
*/
|
|
835
|
-
|
|
836
|
-
this.#
|
|
883
|
+
onBoardChanged(listener) {
|
|
884
|
+
this.#boardChanged = listener;
|
|
837
885
|
}
|
|
838
886
|
/**
|
|
839
887
|
* Fires after any committed write leaves a pending start or deferred decision
|
|
@@ -882,20 +930,109 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
882
930
|
FACTORY_WORK_ITEMS_SCHEMA,
|
|
883
931
|
FACTORY_WORK_ITEM_SOURCES_SCHEMA,
|
|
884
932
|
FACTORY_WORK_ITEM_SPLIT_LOCKS_SCHEMA,
|
|
933
|
+
FACTORY_WORK_ITEM_SPLIT_STATE_SCHEMA,
|
|
885
934
|
FACTORY_BOARD_ITEMS_SCHEMA,
|
|
886
935
|
FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA,
|
|
887
936
|
FACTORY_BOARD_VERSIONS_SCHEMA,
|
|
888
937
|
...FACTORY_GOVERNANCE_SCHEMAS,
|
|
889
|
-
WORK_ITEM_COMMENTS_SCHEMA,
|
|
890
|
-
WORK_ITEM_COMMENT_MENTIONS_SCHEMA,
|
|
891
|
-
WORK_ITEM_ACTIVITY_SCHEMA,
|
|
892
938
|
FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA
|
|
893
939
|
]);
|
|
894
940
|
if (this.#legacyMode && await super.ops.findOne(FACTORY_BOARD_ITEMS_SCHEMA.name, {})) throw new WorkItemSplitModeError("MASTRA_FACTORY_WORK_ITEM_SPLIT=dry-run cannot serve a database with migrated board items.");
|
|
895
|
-
|
|
896
|
-
|
|
941
|
+
if (this.#legacyMode) {
|
|
942
|
+
this.#split = {
|
|
943
|
+
pending: false,
|
|
944
|
+
since: null
|
|
945
|
+
};
|
|
946
|
+
await migrateWorkItemSplit(this.storage, {
|
|
947
|
+
dryRun: true,
|
|
948
|
+
ops: super.ops,
|
|
949
|
+
log: logSplit
|
|
950
|
+
});
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const [marker, newest] = await Promise.all([readWorkItemSplitMarker(super.ops), readLegacyWatermark(super.ops)]);
|
|
954
|
+
const finished = !newest || marker !== null && sameWatermark(marker.watermark, newest);
|
|
955
|
+
this.#split = {
|
|
956
|
+
pending: !finished,
|
|
957
|
+
since: marker?.watermark ?? null
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Copy the legacy cards `isTerminal` rejects, before Factory serves. Terminal cards are left
|
|
962
|
+
* to `backfillLegacyCards`. A no-op once the split finished.
|
|
963
|
+
*/
|
|
964
|
+
async migrateOpenLegacyCards(isTerminal) {
|
|
965
|
+
if (this.#legacyMode || !this.#split.pending) return null;
|
|
966
|
+
return migrateWorkItemSplit(this.storage, {
|
|
897
967
|
ops: super.ops,
|
|
898
|
-
|
|
968
|
+
since: this.#split.since,
|
|
969
|
+
pageSize: OPEN_PASS_PAGE_SIZE,
|
|
970
|
+
include: async (row) => !await isTerminal(toWorkItem(row)),
|
|
971
|
+
label: "boot pass",
|
|
972
|
+
log: logSplit
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Copy every remaining legacy card, then record the newest legacy row seen before the pass
|
|
977
|
+
* began, so later boots skip rows up to it. Skipped cards are logged and count as done: they
|
|
978
|
+
* conflict with newer split state and a rescan would only skip them again.
|
|
979
|
+
*/
|
|
980
|
+
async backfillLegacyCards({ signal } = {}) {
|
|
981
|
+
if (this.#legacyMode || !this.#split.pending) return null;
|
|
982
|
+
const watermark = await readLegacyWatermark(super.ops);
|
|
983
|
+
const report = await migrateWorkItemSplit(this.storage, {
|
|
984
|
+
ops: super.ops,
|
|
985
|
+
since: this.#split.since,
|
|
986
|
+
signal,
|
|
987
|
+
label: "background pass",
|
|
988
|
+
log: logSplit
|
|
989
|
+
});
|
|
990
|
+
if (!report.aborted) {
|
|
991
|
+
await recordWorkItemSplitComplete(super.ops, watermark);
|
|
992
|
+
this.#split = {
|
|
993
|
+
pending: false,
|
|
994
|
+
since: watermark
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
return report;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Copy the legacy cards filed for these external records, so a lookup that matches on `list()`
|
|
1001
|
+
* finds them. A no-op once the split finished.
|
|
1002
|
+
*/
|
|
1003
|
+
async copyLegacyCards({ orgId, factoryProjectId, sources }) {
|
|
1004
|
+
if (this.#legacyMode || !this.#split.pending || !sources.length) return;
|
|
1005
|
+
const sourceKeys = new Set(sources.map((source) => externalSourceKey(source)));
|
|
1006
|
+
await this.#cards(this.#db, { transaction: false }).findMany({
|
|
1007
|
+
org_id: orgId,
|
|
1008
|
+
factory_project_id: factoryProjectId,
|
|
1009
|
+
source_key: { in: [...sourceKeys] }
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Card row access. While legacy cards remain uncopied, a lookup that misses copies the card:
|
|
1014
|
+
* inside the caller's transaction when `ops` is one (a nested transaction would deadlock
|
|
1015
|
+
* LibSQL), else in a transaction of its own.
|
|
1016
|
+
*/
|
|
1017
|
+
#cards(ops, { transaction }) {
|
|
1018
|
+
if (this.#legacyMode || !this.#split.pending) return new Cards(ops, this.#legacyMode, void 0, this.#reviewInUse);
|
|
1019
|
+
return new Cards(ops, false, { copy: async (rows) => {
|
|
1020
|
+
if (transaction) {
|
|
1021
|
+
await copyLegacyRows(ops, rows);
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
try {
|
|
1025
|
+
await this.#withTransaction((tx) => copyLegacyRows(tx, rows));
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
if (!(error instanceof UniqueViolationError)) throw error;
|
|
1028
|
+
}
|
|
1029
|
+
} }, this.#reviewInUse);
|
|
1030
|
+
}
|
|
1031
|
+
/** Validation reads the split tables only, so a parent still in legacy is copied first. */
|
|
1032
|
+
async #copyLegacyParent(ops, orgId, parentId) {
|
|
1033
|
+
if (parentId && this.#split.pending) await this.#cards(ops, { transaction: true }).findOne({
|
|
1034
|
+
org_id: orgId,
|
|
1035
|
+
id: parentId
|
|
899
1036
|
});
|
|
900
1037
|
}
|
|
901
1038
|
/** Refresh source evidence without changing work identity or board concurrency tokens. */
|
|
@@ -930,11 +1067,60 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
930
1067
|
};
|
|
931
1068
|
});
|
|
932
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* File one more external record on an existing card: a pull request on the
|
|
1072
|
+
* issue card it fixes. The card's primary source stays first, so the card keeps
|
|
1073
|
+
* reading as the issue. Attaching a source the card already holds is a no-op
|
|
1074
|
+
* (`attached: false`); one another card holds throws
|
|
1075
|
+
* {@link WorkItemSourceConflictError}. Later state for the attached record goes
|
|
1076
|
+
* through {@link syncWorkItemSource}, never {@link syncCard}, which writes the
|
|
1077
|
+
* primary source.
|
|
1078
|
+
*/
|
|
1079
|
+
async attachSource({ orgId, id, source, metadata, expectedRevision }) {
|
|
1080
|
+
let result;
|
|
1081
|
+
try {
|
|
1082
|
+
result = await this.#withTransaction(async (ops) => {
|
|
1083
|
+
const attached = await new Cards(ops, this.#legacyMode, void 0, this.#reviewInUse).attachSource({
|
|
1084
|
+
org_id: orgId,
|
|
1085
|
+
id
|
|
1086
|
+
}, {
|
|
1087
|
+
external_source: source,
|
|
1088
|
+
metadata,
|
|
1089
|
+
now: /* @__PURE__ */ new Date()
|
|
1090
|
+
}, expectedRevision);
|
|
1091
|
+
if (attached?.ownerWorkItemId) throw new WorkItemSourceConflictError(attached.ownerWorkItemId);
|
|
1092
|
+
if (attached?.revisionConflict) throw new WorkItemUpdateConflictError("revision");
|
|
1093
|
+
return attached;
|
|
1094
|
+
});
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
if (error instanceof UniqueViolationError && error.collection === FACTORY_WORK_ITEM_SOURCES_SCHEMA.name) {
|
|
1097
|
+
const card = await new Cards(this.#db, this.#legacyMode, void 0, this.#reviewInUse).findOne({
|
|
1098
|
+
org_id: orgId,
|
|
1099
|
+
id
|
|
1100
|
+
});
|
|
1101
|
+
const owner = card ? await this.#db.findOne(FACTORY_WORK_ITEM_SOURCES_SCHEMA.name, {
|
|
1102
|
+
org_id: orgId,
|
|
1103
|
+
factory_project_id: card.factory_project_id,
|
|
1104
|
+
source_key: externalSourceKey(source)
|
|
1105
|
+
}) : null;
|
|
1106
|
+
if (owner && card && owner.work_item_id === card.work_item?.id) return {
|
|
1107
|
+
item: toWorkItem(card),
|
|
1108
|
+
attached: false
|
|
1109
|
+
};
|
|
1110
|
+
throw new WorkItemSourceConflictError(owner?.work_item_id ?? "unknown");
|
|
1111
|
+
}
|
|
1112
|
+
throw error;
|
|
1113
|
+
}
|
|
1114
|
+
return result ? {
|
|
1115
|
+
item: toWorkItem(result.row),
|
|
1116
|
+
attached: result.attached
|
|
1117
|
+
} : null;
|
|
1118
|
+
}
|
|
933
1119
|
/** Apply source facts and their process stamps in one transaction. */
|
|
934
1120
|
async syncCard({ orgId, id, userId, patch, expectedSourceRevision, fillOnly = false }) {
|
|
935
1121
|
return this.#withTransaction(async (ops) => {
|
|
936
1122
|
let previous = emptyPrior();
|
|
937
|
-
const row = await
|
|
1123
|
+
const row = await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
938
1124
|
org_id: orgId,
|
|
939
1125
|
id
|
|
940
1126
|
}, async (current) => {
|
|
@@ -997,7 +1183,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
997
1183
|
});
|
|
998
1184
|
}
|
|
999
1185
|
async dangerouslyClearAll() {
|
|
1000
|
-
await this.#withTransaction((ops) =>
|
|
1186
|
+
await this.#withTransaction((ops) => this.#cards(ops, { transaction: true }).deleteMany({}));
|
|
1001
1187
|
await super.ops.deleteMany(FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA.name, {});
|
|
1002
1188
|
await super.ops.deleteMany(FACTORY_BOARD_VERSIONS_SCHEMA.name, {});
|
|
1003
1189
|
this.#listCache.clear();
|
|
@@ -1007,15 +1193,31 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1007
1193
|
}
|
|
1008
1194
|
get ops() {
|
|
1009
1195
|
const ops = super.ops;
|
|
1010
|
-
|
|
1196
|
+
const cards = trackBoardWrites(ops, CARD_TABLES, async (scope) => {
|
|
1197
|
+
await bumpBoardVersions(ops, [scope]);
|
|
1198
|
+
this.#announceBoard(scope);
|
|
1199
|
+
});
|
|
1200
|
+
return trackClaimableWrites(trackBoardWrites(cards, DECISION_TABLES, (scope) => this.#announceBoard(scope)), (scope) => this.#claimableWork(scope));
|
|
1201
|
+
}
|
|
1202
|
+
/** Only legacy dry-run writes name no project, and no feed is keyed by org alone. */
|
|
1203
|
+
#announceBoard(scope) {
|
|
1204
|
+
if (scope.factoryProjectId) this.#boardChanged({
|
|
1205
|
+
orgId: scope.orgId,
|
|
1206
|
+
factoryProjectId: scope.factoryProjectId
|
|
1207
|
+
});
|
|
1011
1208
|
}
|
|
1012
|
-
/** `storage.withTransaction`, bumping the board
|
|
1209
|
+
/** `storage.withTransaction`, bumping and announcing the board of every project it wrote once it commits. */
|
|
1013
1210
|
async #withTransaction(fn, options) {
|
|
1014
1211
|
const changed = new BoardScopes();
|
|
1212
|
+
const touched = new BoardScopes();
|
|
1213
|
+
const cardWritten = (scope) => {
|
|
1214
|
+
changed.add(scope);
|
|
1215
|
+
touched.add(scope);
|
|
1216
|
+
};
|
|
1015
1217
|
let queued = /* @__PURE__ */ new Map();
|
|
1016
1218
|
const run = () => {
|
|
1017
1219
|
queued = /* @__PURE__ */ new Map();
|
|
1018
|
-
return this.storage.withTransaction((ops) => fn(trackClaimableWrites(trackBoardWrites(ops,
|
|
1220
|
+
return this.storage.withTransaction((ops) => fn(trackClaimableWrites(trackBoardWrites(trackBoardWrites(ops, CARD_TABLES, cardWritten), DECISION_TABLES, touched.add), (scope) => queued.set(`${scope.orgId}\u0000${scope.factoryProjectId}`, scope))), options);
|
|
1019
1221
|
};
|
|
1020
1222
|
let result;
|
|
1021
1223
|
try {
|
|
@@ -1029,6 +1231,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1029
1231
|
} finally {
|
|
1030
1232
|
for (const scope of queued.values()) this.#claimableWork(scope);
|
|
1031
1233
|
}
|
|
1234
|
+
for (const scope of touched.values()) this.#announceBoard(scope);
|
|
1032
1235
|
return result;
|
|
1033
1236
|
}
|
|
1034
1237
|
async #countRows(collection, where) {
|
|
@@ -1152,12 +1355,40 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1152
1355
|
return failed ? row : null;
|
|
1153
1356
|
}
|
|
1154
1357
|
async #listWithOps(ops, orgId, factoryProjectId) {
|
|
1155
|
-
return (await
|
|
1358
|
+
return (await this.#cards(ops, { transaction: true }).findMany({
|
|
1156
1359
|
org_id: orgId,
|
|
1157
1360
|
factory_project_id: factoryProjectId
|
|
1158
1361
|
}, { orderBy: [["created_at", "desc"], ["id", "desc"]] })).map(toWorkItem);
|
|
1159
1362
|
}
|
|
1160
1363
|
/**
|
|
1364
|
+
* `previous` updated with the cards changed or deleted since `since`. Reads from a few seconds
|
|
1365
|
+
* earlier so a writer whose clock runs behind this one is still caught.
|
|
1366
|
+
*/
|
|
1367
|
+
async #listDelta(orgId, factoryProjectId, previous, since) {
|
|
1368
|
+
const from = /* @__PURE__ */ new Date(since - LIST_DELTA_CLOCK_SKEW_MS);
|
|
1369
|
+
const scope = {
|
|
1370
|
+
org_id: orgId,
|
|
1371
|
+
factory_project_id: factoryProjectId
|
|
1372
|
+
};
|
|
1373
|
+
const [rows, tombstones] = await Promise.all([this.#cards(super.ops, { transaction: true }).findMany(scope, {
|
|
1374
|
+
orderBy: [["changed_at", "asc"]],
|
|
1375
|
+
cursor: { values: [from] }
|
|
1376
|
+
}), super.ops.findMany(FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA.name, scope, {
|
|
1377
|
+
orderBy: [["deleted_at", "asc"]],
|
|
1378
|
+
cursor: { values: [from] }
|
|
1379
|
+
})]);
|
|
1380
|
+
if (rows.length === 0 && tombstones.length === 0) return [...previous];
|
|
1381
|
+
const changed = new Map(rows.map((row) => [row.id, toWorkItem(row)]));
|
|
1382
|
+
const deleted = new Set(tombstones.map((row) => row.id));
|
|
1383
|
+
const items = previous.filter((item) => !changed.has(item.id) && !deleted.has(item.id));
|
|
1384
|
+
for (const item of changed.values()) if (!deleted.has(item.id)) items.push(item);
|
|
1385
|
+
return items.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() || (a.id < b.id ? 1 : a.id > b.id ? -1 : 0));
|
|
1386
|
+
}
|
|
1387
|
+
/** The project's cards as {@link list} reads them, uncached, through `ops`: a transaction's, to read them in it. */
|
|
1388
|
+
async listWith(ops, { orgId, factoryProjectId }) {
|
|
1389
|
+
return this.#listWithOps(ops, orgId, factoryProjectId);
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1161
1392
|
* List the org's work items for a project, newest first. Ordered on `created_at` with an id
|
|
1162
1393
|
* tiebreak so the order is stable: `updated_at` moves under every write, which makes it useless
|
|
1163
1394
|
* as a cursor and non-deterministic for the callers that iterate this list.
|
|
@@ -1169,7 +1400,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1169
1400
|
/**
|
|
1170
1401
|
* Same rows as {@link list}, but shared with the list cache instead of cloned: the board poll
|
|
1171
1402
|
* reads every card of the project every few seconds, and cloning thousands of rows per poll
|
|
1172
|
-
* costs more than the query the cache saves.
|
|
1403
|
+
* costs more than the query the cache saves. The cached cards are frozen, so a caller that
|
|
1404
|
+
* writes to one throws instead of changing the board every other caller sees.
|
|
1173
1405
|
*/
|
|
1174
1406
|
async listShared({ orgId, factoryProjectId }) {
|
|
1175
1407
|
return (await this.#listCached(orgId, factoryProjectId)).items;
|
|
@@ -1196,10 +1428,11 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1196
1428
|
items: await inFlight.items,
|
|
1197
1429
|
cached: true
|
|
1198
1430
|
};
|
|
1199
|
-
const
|
|
1431
|
+
const startedAt = Date.now();
|
|
1432
|
+
const read = (hit && startedAt - hit.takenAt < LIST_CACHE_TTL_MS ? this.#listDelta(orgId, factoryProjectId, hit.items, hit.readFrom) : this.#listWithOps(super.ops, orgId, factoryProjectId)).then(deepFreeze);
|
|
1200
1433
|
this.#listInFlight.set(key, {
|
|
1201
1434
|
version,
|
|
1202
|
-
startedAt
|
|
1435
|
+
startedAt,
|
|
1203
1436
|
items: read
|
|
1204
1437
|
});
|
|
1205
1438
|
try {
|
|
@@ -1208,7 +1441,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1208
1441
|
this.#listCache.delete(key);
|
|
1209
1442
|
this.#listCache.set(key, {
|
|
1210
1443
|
version,
|
|
1211
|
-
takenAt: Date.now(),
|
|
1444
|
+
takenAt: hit && startedAt - hit.takenAt < LIST_CACHE_TTL_MS ? hit.takenAt : Date.now(),
|
|
1445
|
+
readFrom: startedAt,
|
|
1212
1446
|
items
|
|
1213
1447
|
});
|
|
1214
1448
|
if (this.#listCache.size > LIST_CACHE_MAX_PROJECTS) this.#listCache.delete(this.#listCache.keys().next().value);
|
|
@@ -1221,9 +1455,32 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1221
1455
|
if (this.#listInFlight.get(key)?.items === read) this.#listInFlight.delete(key);
|
|
1222
1456
|
}
|
|
1223
1457
|
}
|
|
1458
|
+
/**
|
|
1459
|
+
* The cards linked to `item` in its project, its parent and its children, newest first as
|
|
1460
|
+
* {@link list} orders them. Read by id and by the parent index, so the cost does not grow with
|
|
1461
|
+
* the board.
|
|
1462
|
+
*/
|
|
1463
|
+
async listLinked({ item, limit }) {
|
|
1464
|
+
const cards = this.#cards(this.#db, { transaction: false });
|
|
1465
|
+
const scope = {
|
|
1466
|
+
org_id: item.orgId,
|
|
1467
|
+
factory_project_id: item.factoryProjectId
|
|
1468
|
+
};
|
|
1469
|
+
const [parent, children] = await Promise.all([item.parentWorkItemId ? cards.findOne({
|
|
1470
|
+
...scope,
|
|
1471
|
+
id: item.parentWorkItemId
|
|
1472
|
+
}) : null, cards.findMany({
|
|
1473
|
+
...scope,
|
|
1474
|
+
parent_work_item_id: item.id
|
|
1475
|
+
}, {
|
|
1476
|
+
orderBy: [["created_at", "desc"], ["id", "desc"]],
|
|
1477
|
+
limit
|
|
1478
|
+
})]);
|
|
1479
|
+
return (parent ? [parent, ...children] : children).map(toWorkItem).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime() || (a.id < b.id ? 1 : -1)).slice(0, limit);
|
|
1480
|
+
}
|
|
1224
1481
|
async listByIds({ orgId, factoryProjectId, ids }) {
|
|
1225
1482
|
if (ids.length === 0) return [];
|
|
1226
|
-
return (await
|
|
1483
|
+
return (await this.#cards(this.#db, { transaction: false }).findMany({
|
|
1227
1484
|
org_id: orgId,
|
|
1228
1485
|
factory_project_id: factoryProjectId,
|
|
1229
1486
|
id: { in: [...new Set(ids)] }
|
|
@@ -1235,11 +1492,17 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1235
1492
|
* ponytail: org-wide scan per session delete; JSON-path query if it measures.
|
|
1236
1493
|
*/
|
|
1237
1494
|
async clearSessionReferences({ orgId, sessionId }) {
|
|
1238
|
-
const
|
|
1495
|
+
const rows = await this.#db.findMany(this.#legacyMode ? WORK_ITEMS_SCHEMA.name : FACTORY_BOARD_ITEMS_SCHEMA.name, { org_id: orgId });
|
|
1496
|
+
if (this.#split.pending) {
|
|
1497
|
+
const split = new Set(rows.map((row) => row.id));
|
|
1498
|
+
const legacy = await this.#db.findMany(WORK_ITEMS_SCHEMA.name, { org_id: orgId });
|
|
1499
|
+
rows.push(...legacy.filter((row) => !split.has(row.id)));
|
|
1500
|
+
}
|
|
1501
|
+
const holding = rows.filter((row) => Object.values(row.sessions).some((ref) => ref.sessionId === sessionId));
|
|
1239
1502
|
let cleared = 0;
|
|
1240
1503
|
for (const row of holding) {
|
|
1241
1504
|
let changed = false;
|
|
1242
|
-
await this.#withTransaction((ops) =>
|
|
1505
|
+
await this.#withTransaction((ops) => this.#cards(ops, { transaction: true }).updateAtomic({ id: row.id }, (current) => {
|
|
1243
1506
|
const kept = Object.entries(current.sessions).filter(([, ref]) => ref.sessionId !== sessionId);
|
|
1244
1507
|
if (kept.length === Object.keys(current.sessions).length) return null;
|
|
1245
1508
|
changed = true;
|
|
@@ -1254,7 +1517,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1254
1517
|
return cleared;
|
|
1255
1518
|
}
|
|
1256
1519
|
async getByProjectSource({ orgId, factoryProjectId, source }) {
|
|
1257
|
-
const row = await
|
|
1520
|
+
const row = await this.#cards(this.#db, { transaction: false }).findOne({
|
|
1258
1521
|
org_id: orgId,
|
|
1259
1522
|
factory_project_id: factoryProjectId,
|
|
1260
1523
|
source_key: externalSourceKey(source)
|
|
@@ -1262,7 +1525,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1262
1525
|
return row ? toWorkItem(row) : null;
|
|
1263
1526
|
}
|
|
1264
1527
|
async get({ orgId, id }) {
|
|
1265
|
-
const row = await
|
|
1528
|
+
const row = await this.#cards(this.#db, { transaction: false }).findOne({
|
|
1266
1529
|
org_id: orgId,
|
|
1267
1530
|
id
|
|
1268
1531
|
});
|
|
@@ -1275,7 +1538,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1275
1538
|
* `workspaceId` instead. Ambiguous matches resolve to nothing, not a guess.
|
|
1276
1539
|
*/
|
|
1277
1540
|
async getBySource(source) {
|
|
1278
|
-
const rows = await
|
|
1541
|
+
const rows = await this.#cards(this.#db, { transaction: false }).findMany({ source_key: externalSourceKey(source) });
|
|
1279
1542
|
return rows.length === 1 ? toWorkItem(rows[0]) : null;
|
|
1280
1543
|
}
|
|
1281
1544
|
/**
|
|
@@ -1285,13 +1548,13 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1285
1548
|
* consults this before creating another.
|
|
1286
1549
|
*/
|
|
1287
1550
|
async listBySource({ orgId, source }) {
|
|
1288
|
-
return (await
|
|
1551
|
+
return (await this.#cards(this.#db, { transaction: false }).findMany({
|
|
1289
1552
|
org_id: orgId,
|
|
1290
1553
|
source_key: externalSourceKey(source)
|
|
1291
1554
|
})).map(toWorkItem);
|
|
1292
1555
|
}
|
|
1293
1556
|
async getForProject(orgId, factoryProjectId, id) {
|
|
1294
|
-
const row = await
|
|
1557
|
+
const row = await this.#cards(this.#db, { transaction: false }).findOne({
|
|
1295
1558
|
id,
|
|
1296
1559
|
org_id: orgId,
|
|
1297
1560
|
factory_project_id: factoryProjectId
|
|
@@ -1313,7 +1576,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1313
1576
|
identity: input.ingress.identity
|
|
1314
1577
|
});
|
|
1315
1578
|
if (prior) {
|
|
1316
|
-
const row = await
|
|
1579
|
+
const row = await this.#cards(ops, { transaction: true }).findOne({
|
|
1317
1580
|
id: input.workItemId,
|
|
1318
1581
|
org_id: input.orgId,
|
|
1319
1582
|
factory_project_id: input.factoryProjectId
|
|
@@ -1329,7 +1592,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1329
1592
|
let code = null;
|
|
1330
1593
|
let reason = null;
|
|
1331
1594
|
let result;
|
|
1332
|
-
const updated = await
|
|
1595
|
+
const updated = await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
1333
1596
|
id: input.workItemId,
|
|
1334
1597
|
org_id: input.orgId,
|
|
1335
1598
|
factory_project_id: input.factoryProjectId
|
|
@@ -1474,7 +1737,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1474
1737
|
for (const decision of decisions) {
|
|
1475
1738
|
if (!evaluation || !decision || typeof decision !== "object" || decision.type !== "upsertLinkedWorkItem" || !isWorkItemSource(decision.source) || typeof decision.sourceKey !== "string" || typeof decision.idempotencyKey !== "string") continue;
|
|
1476
1739
|
const materialization = decision;
|
|
1477
|
-
if (await
|
|
1740
|
+
if (await this.#cards(ops, { transaction: true }).findOne({
|
|
1478
1741
|
org_id: input.orgId,
|
|
1479
1742
|
factory_project_id: input.factoryProjectId,
|
|
1480
1743
|
source_key: externalSourceKey(externalSourceForWorkItem(materialization.source, materialization.sourceKey))
|
|
@@ -1500,7 +1763,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1500
1763
|
result
|
|
1501
1764
|
};
|
|
1502
1765
|
}
|
|
1503
|
-
const itemRow = input.workItemId ? await
|
|
1766
|
+
const itemRow = input.workItemId ? await this.#cards(ops, { transaction: true }).findOne({
|
|
1504
1767
|
id: input.workItemId,
|
|
1505
1768
|
org_id: input.orgId,
|
|
1506
1769
|
factory_project_id: input.factoryProjectId
|
|
@@ -1750,28 +2013,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1750
2013
|
});
|
|
1751
2014
|
return Boolean(decision) && parked;
|
|
1752
2015
|
}
|
|
1753
|
-
|
|
1754
|
-
if (identity.kind === "activity") return await ops.findOne("work_item_activity", {
|
|
1755
|
-
work_item_id: identity.sourceId,
|
|
1756
|
-
participant_id: userId,
|
|
1757
|
-
org_id: orgId,
|
|
1758
|
-
factory_project_id: factoryProjectId,
|
|
1759
|
-
occurrence: identity.occurrence
|
|
1760
|
-
}) !== null;
|
|
1761
|
-
if (identity.occurrence !== 0) return false;
|
|
1762
|
-
if (!await ops.findOne("work_item_comment_mentions", {
|
|
1763
|
-
comment_id: identity.sourceId,
|
|
1764
|
-
org_id: orgId,
|
|
1765
|
-
factory_project_id: factoryProjectId,
|
|
1766
|
-
mentioned_kind: "user",
|
|
1767
|
-
mentioned_id: userId
|
|
1768
|
-
})) return false;
|
|
1769
|
-
return await ops.findOne("work_item_comments", {
|
|
1770
|
-
id: identity.sourceId,
|
|
1771
|
-
org_id: orgId,
|
|
1772
|
-
factory_project_id: factoryProjectId,
|
|
1773
|
-
deleted_at: null
|
|
1774
|
-
}) !== null;
|
|
2016
|
+
return true;
|
|
1775
2017
|
}
|
|
1776
2018
|
async #setAttentionReceiptWithOps(ops, { orgId, factoryProjectId, userId, identity, action, now }) {
|
|
1777
2019
|
if (!await this.#attentionSourceIsCurrent(ops, {
|
|
@@ -1845,12 +2087,33 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1845
2087
|
const row = await this.#completeLease("factory_deferred_decisions", identity, now, "superseded");
|
|
1846
2088
|
return row ? toDeferredDecision(row) : null;
|
|
1847
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Hand a leased decision back untouched until `availableAt`: it could not act yet and did
|
|
2092
|
+
* nothing, so the claim is not an attempt and leaves no error behind.
|
|
2093
|
+
*/
|
|
2094
|
+
async postponeDeferredDecision(identity, availableAt, now) {
|
|
2095
|
+
let postponed = false;
|
|
2096
|
+
const row = await this.#db.updateAtomic("factory_deferred_decisions", {
|
|
2097
|
+
id: identity.id,
|
|
2098
|
+
org_id: identity.orgId,
|
|
2099
|
+
factory_project_id: identity.factoryProjectId
|
|
2100
|
+
}, (current) => {
|
|
2101
|
+
if (current.status !== "leased" || current.lease_owner !== identity.ownerId) return null;
|
|
2102
|
+
postponed = true;
|
|
2103
|
+
return {
|
|
2104
|
+
status: "pending",
|
|
2105
|
+
attempts: Math.max(0, Number(current.attempts) - 1),
|
|
2106
|
+
available_at: availableAt,
|
|
2107
|
+
lease_owner: null,
|
|
2108
|
+
lease_expires_at: null,
|
|
2109
|
+
updated_at: now
|
|
2110
|
+
};
|
|
2111
|
+
});
|
|
2112
|
+
return postponed && row ? toDeferredDecision(row) : null;
|
|
2113
|
+
}
|
|
1848
2114
|
async failDeferredDecision(input) {
|
|
1849
2115
|
const row = await this.#failLease("factory_deferred_decisions", input);
|
|
1850
|
-
|
|
1851
|
-
const record = toDeferredDecision(row);
|
|
1852
|
-
if (input.terminal) this.#attentionChanged(record);
|
|
1853
|
-
return record;
|
|
2116
|
+
return row ? toDeferredDecision(row) : null;
|
|
1854
2117
|
}
|
|
1855
2118
|
/** Park a claimed effect for human approval; the dispatcher never claims `proposed` rows. */
|
|
1856
2119
|
async proposeDeferredDecision(identity, now) {
|
|
@@ -1870,10 +2133,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1870
2133
|
updated_at: now
|
|
1871
2134
|
};
|
|
1872
2135
|
});
|
|
1873
|
-
|
|
1874
|
-
const record = toDeferredDecision(row);
|
|
1875
|
-
this.#attentionChanged(record);
|
|
1876
|
-
return record;
|
|
2136
|
+
return proposed && row ? toDeferredDecision(row) : null;
|
|
1877
2137
|
}
|
|
1878
2138
|
/**
|
|
1879
2139
|
* Release an approved effect back to the dispatcher; only `proposed` rows are
|
|
@@ -1882,7 +2142,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1882
2142
|
* leaving its follow-up work parked for re-approval.
|
|
1883
2143
|
*/
|
|
1884
2144
|
async approveDeferredDecision(orgId, factoryProjectId, decisionId, now, approvedBy) {
|
|
1885
|
-
|
|
2145
|
+
return this.#withTransaction(async (ops) => {
|
|
1886
2146
|
let settled = false;
|
|
1887
2147
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
1888
2148
|
id: decisionId,
|
|
@@ -1903,14 +2163,12 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1903
2163
|
if (!settled || !row) return null;
|
|
1904
2164
|
const record = toDeferredDecision(row);
|
|
1905
2165
|
await ops.deleteMany("factory_attention_receipts", proposalReceiptFilter(orgId, factoryProjectId, decisionId));
|
|
1906
|
-
if (record.workItemId) await
|
|
2166
|
+
if (record.workItemId) await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
1907
2167
|
org_id: orgId,
|
|
1908
2168
|
id: record.workItemId
|
|
1909
2169
|
}, (current) => current.autonomy_armed_at ? null : { autonomy_armed_at: now });
|
|
1910
2170
|
return record;
|
|
1911
2171
|
});
|
|
1912
|
-
if (approved) this.#attentionChanged(approved);
|
|
1913
|
-
return approved;
|
|
1914
2172
|
}
|
|
1915
2173
|
/** Retire a proposal nobody wants: `dismissed` is terminal, so the run never happens. */
|
|
1916
2174
|
async dismissDeferredDecision(orgId, factoryProjectId, decisionId, now) {
|
|
@@ -1958,7 +2216,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1958
2216
|
return superseded;
|
|
1959
2217
|
}
|
|
1960
2218
|
async #settleProposedDecision({ orgId, factoryProjectId, decisionId }, patch) {
|
|
1961
|
-
|
|
2219
|
+
return this.#withTransaction(async (ops) => {
|
|
1962
2220
|
let updated = false;
|
|
1963
2221
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
1964
2222
|
id: decisionId,
|
|
@@ -1973,11 +2231,9 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1973
2231
|
await ops.deleteMany("factory_attention_receipts", proposalReceiptFilter(orgId, factoryProjectId, decisionId));
|
|
1974
2232
|
return toDeferredDecision(row);
|
|
1975
2233
|
});
|
|
1976
|
-
if (settled) this.#attentionChanged(settled);
|
|
1977
|
-
return settled;
|
|
1978
2234
|
}
|
|
1979
2235
|
async #supersedeFailedDecision({ orgId, factoryProjectId, decisionId, now }) {
|
|
1980
|
-
|
|
2236
|
+
return this.#withTransaction(async (ops) => {
|
|
1981
2237
|
let resolved = false;
|
|
1982
2238
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
1983
2239
|
id: decisionId,
|
|
@@ -2001,8 +2257,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2001
2257
|
});
|
|
2002
2258
|
return toDeferredDecision(row);
|
|
2003
2259
|
});
|
|
2004
|
-
if (resolved) this.#attentionChanged(resolved);
|
|
2005
|
-
return resolved;
|
|
2006
2260
|
}
|
|
2007
2261
|
async supersedeTerminalDecisionsForWorkItem(input) {
|
|
2008
2262
|
await this.supersedeDecisionsForWorkItem(input);
|
|
@@ -2014,8 +2268,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2014
2268
|
* left alone. Returns the cards moved; a second run finds none.
|
|
2015
2269
|
*/
|
|
2016
2270
|
async returnHeldTriageCards() {
|
|
2017
|
-
const held = (await
|
|
2018
|
-
board: { in: [
|
|
2271
|
+
const held = (await this.#cards(this.#db, { transaction: false }).findMany({
|
|
2272
|
+
board: { in: [LEGACY_WORK_BOARD, null] },
|
|
2019
2273
|
triage_type: { in: FACTORY_TRIAGE_TYPES.filter((type) => type !== "bug") },
|
|
2020
2274
|
accepted_at: null
|
|
2021
2275
|
})).map(toWorkItem).filter((item) => item.stages.length === 1 && item.stages[0] === "triage" && (item.board === "work" || item.externalSource?.type !== "pull-request"));
|
|
@@ -2037,7 +2291,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2037
2291
|
factoryProjectId: item.factoryProjectId,
|
|
2038
2292
|
workItemId: item.id,
|
|
2039
2293
|
expectedRevision: item.revision,
|
|
2040
|
-
destinationStage:
|
|
2294
|
+
destinationStage: LEGACY_REST_PHASE,
|
|
2041
2295
|
actorId: HELD_CARD_SWEEP_ACTOR,
|
|
2042
2296
|
ingress: {
|
|
2043
2297
|
identity,
|
|
@@ -2058,7 +2312,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2058
2312
|
}
|
|
2059
2313
|
/** Requeue the same idempotent terminal effect; non-failed or non-retryable decisions are never rerun. */
|
|
2060
2314
|
async retryDeferredDecision(orgId, factoryProjectId, decisionId, now) {
|
|
2061
|
-
|
|
2315
|
+
return this.#withTransaction(async (ops) => {
|
|
2062
2316
|
let retried = false;
|
|
2063
2317
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
2064
2318
|
id: decisionId,
|
|
@@ -2092,8 +2346,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2092
2346
|
});
|
|
2093
2347
|
return toDeferredDecision(row);
|
|
2094
2348
|
});
|
|
2095
|
-
if (retriedRecord) this.#attentionChanged(retriedRecord);
|
|
2096
|
-
return retriedRecord;
|
|
2097
2349
|
}
|
|
2098
2350
|
/** Resolve exact active agent authority; partial session matches never authorize. */
|
|
2099
2351
|
async findActiveRunBinding(address) {
|
|
@@ -2274,12 +2526,13 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2274
2526
|
resource_id: input.sessionId
|
|
2275
2527
|
}, { resource_id: input.resourceId });
|
|
2276
2528
|
}
|
|
2277
|
-
/** List binding history, optionally narrowed to one work
|
|
2529
|
+
/** List binding history, optionally narrowed to one or some work items. */
|
|
2278
2530
|
async listRunBindings(orgId, factoryProjectId, workItemId) {
|
|
2531
|
+
if (Array.isArray(workItemId) && workItemId.length === 0) return [];
|
|
2279
2532
|
return (await this.#db.findMany("factory_run_bindings", {
|
|
2280
2533
|
org_id: orgId,
|
|
2281
2534
|
factory_project_id: factoryProjectId,
|
|
2282
|
-
...workItemId ? { work_item_id: workItemId } : {}
|
|
2535
|
+
...workItemId ? { work_item_id: Array.isArray(workItemId) ? { in: workItemId } : workItemId } : {}
|
|
2283
2536
|
}, { orderBy: [["created_at", "asc"]] })).map(toBinding);
|
|
2284
2537
|
}
|
|
2285
2538
|
async listPendingStarts(orgId, factoryProjectId) {
|
|
@@ -2315,7 +2568,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2315
2568
|
org_id: input.orgId,
|
|
2316
2569
|
factory_project_id: input.factoryProjectId
|
|
2317
2570
|
});
|
|
2318
|
-
const itemRow = bindingRow && await
|
|
2571
|
+
const itemRow = bindingRow && await this.#cards(ops, { transaction: true }).findOne({
|
|
2319
2572
|
id: String(bindingRow.work_item_id),
|
|
2320
2573
|
org_id: input.orgId,
|
|
2321
2574
|
factory_project_id: input.factoryProjectId
|
|
@@ -2334,18 +2587,18 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2334
2587
|
}
|
|
2335
2588
|
const now = /* @__PURE__ */ new Date();
|
|
2336
2589
|
const create = input.workItem.input;
|
|
2337
|
-
let row = input.workItem.id ? await
|
|
2590
|
+
let row = input.workItem.id ? await this.#cards(ops, { transaction: true }).findOne({
|
|
2338
2591
|
id: input.workItem.id,
|
|
2339
2592
|
org_id: input.orgId,
|
|
2340
2593
|
factory_project_id: input.factoryProjectId
|
|
2341
|
-
}) : externalSourceKey(create.externalSource) ? await
|
|
2594
|
+
}) : externalSourceKey(create.externalSource) ? await this.#cards(ops, { transaction: true }).findOne({
|
|
2342
2595
|
org_id: input.orgId,
|
|
2343
2596
|
factory_project_id: input.factoryProjectId,
|
|
2344
2597
|
source_key: externalSourceKey(create.externalSource)
|
|
2345
2598
|
}) : null;
|
|
2346
2599
|
let item;
|
|
2347
2600
|
if (row) {
|
|
2348
|
-
row = await
|
|
2601
|
+
row = await this.#cards(ops, { transaction: true }).updateAtomic({ id: row.id }, (current) => {
|
|
2349
2602
|
return applyUpdate({
|
|
2350
2603
|
current,
|
|
2351
2604
|
userId: input.userId,
|
|
@@ -2355,11 +2608,12 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2355
2608
|
});
|
|
2356
2609
|
item = toRow(row);
|
|
2357
2610
|
} else {
|
|
2358
|
-
if (create.parentWorkItemId)
|
|
2611
|
+
if (create.parentWorkItemId) await this.#copyLegacyParent(ops, input.orgId, create.parentWorkItemId);
|
|
2612
|
+
if (create.parentWorkItemId) validateParentRelation((await this.#cards(ops, { transaction: true }).findMany({
|
|
2359
2613
|
org_id: input.orgId,
|
|
2360
2614
|
factory_project_id: input.factoryProjectId
|
|
2361
2615
|
})).map(toRow), void 0, create.parentWorkItemId);
|
|
2362
|
-
row = await
|
|
2616
|
+
row = await this.#cards(ops, { transaction: true }).insertOne({
|
|
2363
2617
|
org_id: input.orgId,
|
|
2364
2618
|
created_by: input.userId,
|
|
2365
2619
|
factory_project_id: input.factoryProjectId,
|
|
@@ -2368,6 +2622,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2368
2622
|
source_key: externalSourceKey(create.externalSource),
|
|
2369
2623
|
parent_work_item_id: create.parentWorkItemId ?? null,
|
|
2370
2624
|
title: create.title,
|
|
2625
|
+
description: create.description ?? null,
|
|
2371
2626
|
stages: create.stages ?? [],
|
|
2372
2627
|
stage_history: applyStageTransition([], [], create.stages ?? [], input.userId, now),
|
|
2373
2628
|
sessions: stampSessions({ [input.role]: input.session }, input.userId),
|
|
@@ -2485,7 +2740,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2485
2740
|
const key = externalSourceKey(input.externalSource);
|
|
2486
2741
|
const reuse = async () => {
|
|
2487
2742
|
if (!key) return null;
|
|
2488
|
-
const existing = await
|
|
2743
|
+
const existing = await this.#cards(ops, { transaction: true }).findOne({
|
|
2489
2744
|
org_id: orgId,
|
|
2490
2745
|
factory_project_id: factoryProjectId,
|
|
2491
2746
|
source_key: key
|
|
@@ -2497,7 +2752,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2497
2752
|
previous: priorState(existing)
|
|
2498
2753
|
};
|
|
2499
2754
|
let previous = emptyPrior();
|
|
2500
|
-
const updated = await
|
|
2755
|
+
const updated = await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
2501
2756
|
org_id: orgId,
|
|
2502
2757
|
factory_project_id: factoryProjectId,
|
|
2503
2758
|
source_key: key
|
|
@@ -2509,10 +2764,14 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2509
2764
|
} : input;
|
|
2510
2765
|
const patch = reuseMode === "non-stage" ? {
|
|
2511
2766
|
title: input.title,
|
|
2767
|
+
description: input.description,
|
|
2512
2768
|
parentWorkItemId: input.parentWorkItemId ?? void 0,
|
|
2513
2769
|
metadata: input.metadata
|
|
2514
2770
|
} : fullPatch;
|
|
2515
|
-
if (patch.parentWorkItemId !== void 0)
|
|
2771
|
+
if (patch.parentWorkItemId !== void 0) {
|
|
2772
|
+
await this.#copyLegacyParent(ops, orgId, patch.parentWorkItemId);
|
|
2773
|
+
validateParentRelation(await this.#listWithOps(ops, orgId, factoryProjectId), current.id, patch.parentWorkItemId);
|
|
2774
|
+
}
|
|
2516
2775
|
return {
|
|
2517
2776
|
board: reuseMode === "non-stage" ? current.board : input.board ?? current.board ?? null,
|
|
2518
2777
|
external_source: input.externalSource ?? null,
|
|
@@ -2533,9 +2792,12 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2533
2792
|
if (reused) return reused;
|
|
2534
2793
|
const now = /* @__PURE__ */ new Date();
|
|
2535
2794
|
const stages = input.stages ?? ["intake"];
|
|
2536
|
-
|
|
2795
|
+
if (input.parentWorkItemId != null) {
|
|
2796
|
+
await this.#copyLegacyParent(ops, orgId, input.parentWorkItemId);
|
|
2797
|
+
validateParentRelation(await this.#listWithOps(ops, orgId, factoryProjectId), void 0, input.parentWorkItemId);
|
|
2798
|
+
}
|
|
2537
2799
|
return {
|
|
2538
|
-
item: toWorkItem(await
|
|
2800
|
+
item: toWorkItem(await this.#cards(ops, { transaction: true }).insertOne({
|
|
2539
2801
|
org_id: orgId,
|
|
2540
2802
|
factory_project_id: factoryProjectId,
|
|
2541
2803
|
board: input.board ?? null,
|
|
@@ -2543,6 +2805,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2543
2805
|
source_key: key,
|
|
2544
2806
|
parent_work_item_id: input.parentWorkItemId ?? null,
|
|
2545
2807
|
title: input.title,
|
|
2808
|
+
description: input.description ?? null,
|
|
2546
2809
|
stages,
|
|
2547
2810
|
stage_history: stages.map((stage) => ({
|
|
2548
2811
|
stage,
|
|
@@ -2561,17 +2824,18 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2561
2824
|
};
|
|
2562
2825
|
}
|
|
2563
2826
|
async setParentWorkItemIfMissing({ orgId, id, userId, parentWorkItemId }) {
|
|
2564
|
-
const candidate = await
|
|
2827
|
+
const candidate = await this.#cards(this.#db, { transaction: false }).findOne({
|
|
2565
2828
|
org_id: orgId,
|
|
2566
2829
|
id
|
|
2567
2830
|
});
|
|
2568
2831
|
if (!candidate) return null;
|
|
2569
2832
|
return this.#withProjectRelationTransaction(orgId, candidate.factory_project_id, async (ops) => {
|
|
2570
|
-
const row = await
|
|
2833
|
+
const row = await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
2571
2834
|
org_id: orgId,
|
|
2572
2835
|
id
|
|
2573
2836
|
}, async (current) => {
|
|
2574
2837
|
if (current.parent_work_item_id !== null) return current;
|
|
2838
|
+
await this.#copyLegacyParent(ops, orgId, parentWorkItemId);
|
|
2575
2839
|
validateParentRelation(await this.#listWithOps(ops, orgId, current.factory_project_id), current.id, parentWorkItemId);
|
|
2576
2840
|
return applyUpdate({
|
|
2577
2841
|
current,
|
|
@@ -2585,14 +2849,17 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2585
2849
|
async update({ orgId, id, userId, patch, expectedRevision, expectedBoard }) {
|
|
2586
2850
|
const run = async (ops) => {
|
|
2587
2851
|
let previous = emptyPrior();
|
|
2588
|
-
const row = await
|
|
2852
|
+
const row = await this.#cards(ops, { transaction: true }).updateAtomic({
|
|
2589
2853
|
org_id: orgId,
|
|
2590
2854
|
id
|
|
2591
2855
|
}, async (current) => {
|
|
2592
2856
|
previous = priorState(current);
|
|
2593
2857
|
if (expectedBoard !== void 0 && current.board !== expectedBoard) throw new WorkItemUpdateConflictError("board");
|
|
2594
2858
|
if (expectedRevision !== void 0 && current.revision !== expectedRevision) throw new WorkItemUpdateConflictError("revision");
|
|
2595
|
-
if (patch.parentWorkItemId !== void 0)
|
|
2859
|
+
if (patch.parentWorkItemId !== void 0) {
|
|
2860
|
+
await this.#copyLegacyParent(ops, orgId, patch.parentWorkItemId);
|
|
2861
|
+
validateParentRelation(await this.#listWithOps(ops, orgId, current.factory_project_id), current.id, patch.parentWorkItemId);
|
|
2862
|
+
}
|
|
2596
2863
|
return applyUpdate({
|
|
2597
2864
|
current,
|
|
2598
2865
|
userId,
|
|
@@ -2605,7 +2872,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2605
2872
|
} : null;
|
|
2606
2873
|
};
|
|
2607
2874
|
if (patch.parentWorkItemId === void 0) return this.#withTransaction(run);
|
|
2608
|
-
const candidate = await
|
|
2875
|
+
const candidate = await this.#cards(this.#db, { transaction: false }).findOne({
|
|
2609
2876
|
org_id: orgId,
|
|
2610
2877
|
id
|
|
2611
2878
|
});
|
|
@@ -2646,41 +2913,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2646
2913
|
for (const ingressId of ingressIds) if ((await ops.findMany("factory_rule_evaluations", { ingress_id: ingressId })).length === 0) await ops.deleteMany("factory_rule_ingress", { id: ingressId });
|
|
2647
2914
|
}
|
|
2648
2915
|
/**
|
|
2649
|
-
* Feed rows die with their work item: orphan mention rows would keep
|
|
2650
|
-
* projecting attention items that deep-link to a card that no longer exists.
|
|
2651
|
-
*/
|
|
2652
|
-
async #purgeFeedState(ops, { orgId, factoryProjectId, workItemId }) {
|
|
2653
|
-
const where = {
|
|
2654
|
-
org_id: orgId,
|
|
2655
|
-
factory_project_id: factoryProjectId,
|
|
2656
|
-
work_item_id: workItemId
|
|
2657
|
-
};
|
|
2658
|
-
while (true) {
|
|
2659
|
-
const comments = await ops.findMany("work_item_comments", where, { limit: ATTENTION_RECEIPT_QUERY_BATCH_SIZE });
|
|
2660
|
-
if (comments.length === 0) break;
|
|
2661
|
-
const commentIds = comments.map((comment) => comment.id);
|
|
2662
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2663
|
-
org_id: orgId,
|
|
2664
|
-
factory_project_id: factoryProjectId,
|
|
2665
|
-
kind: "mention",
|
|
2666
|
-
source_id: { in: commentIds }
|
|
2667
|
-
});
|
|
2668
|
-
await ops.deleteMany("work_item_comments", {
|
|
2669
|
-
...where,
|
|
2670
|
-
id: { in: commentIds }
|
|
2671
|
-
});
|
|
2672
|
-
if (comments.length < ATTENTION_RECEIPT_QUERY_BATCH_SIZE) break;
|
|
2673
|
-
}
|
|
2674
|
-
await ops.deleteMany("work_item_comment_mentions", where);
|
|
2675
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2676
|
-
org_id: orgId,
|
|
2677
|
-
factory_project_id: factoryProjectId,
|
|
2678
|
-
kind: "activity",
|
|
2679
|
-
source_id: workItemId
|
|
2680
|
-
});
|
|
2681
|
-
await ops.deleteMany("work_item_activity", where);
|
|
2682
|
-
}
|
|
2683
|
-
/**
|
|
2684
2916
|
* Make a session follow a work item. Idempotent: following again keeps the
|
|
2685
2917
|
* first subscription, including its reason (filing beats a later subscribe).
|
|
2686
2918
|
*/
|
|
@@ -2741,17 +2973,12 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2741
2973
|
...expectedRevision === void 0 ? {} : { revision: expectedRevision },
|
|
2742
2974
|
...expectedUpdatedAt === void 0 ? {} : { updated_at: expectedUpdatedAt }
|
|
2743
2975
|
};
|
|
2744
|
-
const candidate = await
|
|
2976
|
+
const candidate = await this.#cards(this.#db, { transaction: false }).findOne(where);
|
|
2745
2977
|
if (!candidate) return null;
|
|
2746
|
-
|
|
2747
|
-
const existing = await
|
|
2978
|
+
return this.#withProjectRelationTransaction(orgId, candidate.factory_project_id, async (ops) => {
|
|
2979
|
+
const existing = await this.#cards(ops, { transaction: true }).findOne(where);
|
|
2748
2980
|
if (!existing) return null;
|
|
2749
|
-
if (await
|
|
2750
|
-
await this.#purgeFeedState(ops, {
|
|
2751
|
-
orgId,
|
|
2752
|
-
factoryProjectId: existing.factory_project_id,
|
|
2753
|
-
workItemId: id
|
|
2754
|
-
});
|
|
2981
|
+
if (await this.#cards(ops, { transaction: true }).deleteMany(where) === 0) return null;
|
|
2755
2982
|
await ops.deleteMany(FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA.name, {
|
|
2756
2983
|
org_id: orgId,
|
|
2757
2984
|
work_item_id: id
|
|
@@ -2761,7 +2988,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2761
2988
|
factoryProjectId: existing.factory_project_id,
|
|
2762
2989
|
sourceKeys: [existing.external_source.externalId]
|
|
2763
2990
|
});
|
|
2764
|
-
await
|
|
2991
|
+
await this.#cards(ops, { transaction: true }).updateMany({
|
|
2765
2992
|
org_id: orgId,
|
|
2766
2993
|
parent_work_item_id: id
|
|
2767
2994
|
}, {
|
|
@@ -2770,10 +2997,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2770
2997
|
});
|
|
2771
2998
|
return toWorkItem(existing);
|
|
2772
2999
|
});
|
|
2773
|
-
if (removed) this.#attentionChanged(removed);
|
|
2774
|
-
return removed;
|
|
2775
3000
|
}
|
|
2776
3001
|
};
|
|
2777
|
-
export {
|
|
3002
|
+
export { FACTORY_PULL_REQUEST_RECONCILIATION_KEY, FACTORY_RULE_MATERIALIZATION_KEY, FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA, HELD_CARD_SWEEP_ACTOR, WorkItemRelationError, WorkItemSourceConflictError, WorkItemSplitModeError, WorkItemUpdateConflictError, WorkItemsStorage, applyStageTransition, externalSourceKey, factoryAgentWaitingAttentionIdentity, factoryAttentionKey, factoryDecisionAttentionIdentity, factoryDecisionHash, factoryProposalAttentionIdentity, isAgentActor, stampSessions, validateParentRelation };
|
|
2778
3003
|
|
|
2779
3004
|
//# sourceMappingURL=base.js.map
|