@mastra/factory 0.28.0-alpha.5 → 0.28.0-alpha.7
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 +52 -28
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +5 -5
- package/dist/auth.js.map +1 -1
- package/dist/boards/board-writes.d.ts +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +7 -8
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/index.d.ts +1 -1
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +2 -2
- package/dist/boards/project-boards.d.ts +30 -4
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +71 -19
- 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 +16 -3
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/semantics.d.ts +5 -4
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +5 -4
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +4 -3
- package/dist/boards/work-migrations.d.ts.map +1 -1
- package/dist/boards/work-migrations.js +6 -5
- package/dist/boards/work-migrations.js.map +1 -1
- 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 +2 -2
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +0 -16
- 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 +8 -4
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +57 -59
- package/dist/factory.js.map +1 -1
- package/dist/feed-events.d.ts +2 -3
- package/dist/feed-events.d.ts.map +1 -1
- package/dist/feed-events.js +4 -5
- package/dist/feed-events.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/integrations/base.d.ts +0 -11
- package/dist/integrations/base.d.ts.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.js +2 -2
- 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/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/routes.d.ts +4 -3
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +9 -86
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +67 -0
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +215 -12
- 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/gitlab/merge-request-reconciler.js +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +6 -5
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +5 -2
- 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/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +5 -2
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +1 -1
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +2 -2
- package/dist/integrations/linear/rules.js.map +1 -1
- 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 +21 -3
- package/dist/integrations/platform/github/integration.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 +1 -1
- package/dist/integrations/platform/linear/event-worker.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 +0 -5
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts +3 -18
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +3 -74
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/links.d.ts +1 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +1 -2
- package/dist/links.js.map +1 -1
- package/dist/mcp/routes.js +1 -1
- package/dist/mcp/routes.js.map +1 -1
- package/dist/routes/attention-parked.js +1 -1
- 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 +2 -150
- 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/boards.d.ts +1 -1
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/contracts.d.ts +121 -14
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +73 -3
- 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/knowledge.js +1 -1
- package/dist/routes/projects.d.ts +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +13 -7
- package/dist/routes/projects.js.map +1 -1
- 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/surface.d.ts +0 -7
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +1 -5
- package/dist/routes/surface.js.map +1 -1
- 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 +1 -2
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +0 -3
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +8 -9
- package/dist/rules/dispatcher.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/storage/domains/audit/actions.d.ts +2 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +5 -4
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +15 -1
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +21 -5
- package/dist/storage/domains/boards/base.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/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/work-items/base.d.ts +8 -9
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +20 -86
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +3 -3
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +10 -10
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/metrics.d.ts +1 -1
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -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 +8 -8
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/tools/read-tools.d.ts +0 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +3 -14
- package/dist/tools/read-tools.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 +8 -18
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +3 -2
- 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/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +1 -6
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +3 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +21 -4
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +3 -3
- package/factory-skills/factory-rereview/SKILL.md +2 -2
- package/factory-skills/factory-review/SKILL.md +2 -2
- package/factory-skills/factory-triage/SKILL.md +3 -2
- package/package.json +7 -7
- 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/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
|
@@ -2,7 +2,6 @@ import { factoryDispatchFailureMetadata } from "../../../rules/dispatch-errors.j
|
|
|
2
2
|
import { FACTORY_TRIAGE_TYPES, externalSourceForWorkItem } from "../../../rules/types.js";
|
|
3
3
|
import { workItemProviderAdapter } from "../../../work-items/providers/index.js";
|
|
4
4
|
import { copyLegacyRows, migrateWorkItemSplit, readLegacyWatermark, readWorkItemSplitMarker, recordWorkItemSplitComplete } from "../../../work-items/split-migration.js";
|
|
5
|
-
import { WORK_ITEM_ACTIVITY_SCHEMA, WORK_ITEM_COMMENTS_SCHEMA, WORK_ITEM_COMMENT_MENTIONS_SCHEMA } from "../comments/schema.js";
|
|
6
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";
|
|
@@ -21,6 +20,14 @@ import { FactoryStorageDomain, UniqueViolationError } from "@mastra/core/storage
|
|
|
21
20
|
* atomically so concurrent actors do not overwrite each other. The authoritative
|
|
22
21
|
* Factory transition path keeps one exclusive current stage per item.
|
|
23
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
|
+
}
|
|
24
31
|
function stableJson(value) {
|
|
25
32
|
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
26
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(",")}}`;
|
|
@@ -104,21 +111,6 @@ function proposalReceiptFilter(orgId, factoryProjectId, decisionId) {
|
|
|
104
111
|
occurrence: identity.occurrence
|
|
105
112
|
};
|
|
106
113
|
}
|
|
107
|
-
function factoryMentionAttentionIdentity(commentId) {
|
|
108
|
-
return {
|
|
109
|
-
kind: "mention",
|
|
110
|
-
sourceId: commentId,
|
|
111
|
-
occurrence: 0
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
/** Collapsed per work item, so the occurrence is what a new comment bumps. */
|
|
115
|
-
function factoryActivityAttentionIdentity(workItemId, occurrence) {
|
|
116
|
-
return {
|
|
117
|
-
kind: "activity",
|
|
118
|
-
sourceId: workItemId,
|
|
119
|
-
occurrence
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
114
|
/** Dated by the park itself, so an answer and a new park never share a receipt. */
|
|
123
115
|
function factoryAgentWaitingAttentionIdentity(sessionId, suspendedAt) {
|
|
124
116
|
return {
|
|
@@ -238,6 +230,7 @@ function toWorkItem(row) {
|
|
|
238
230
|
externalSource: row.external_source,
|
|
239
231
|
parentWorkItemId: row.parent_work_item_id,
|
|
240
232
|
title: row.title,
|
|
233
|
+
description: row.description ?? null,
|
|
241
234
|
stages: row.stages,
|
|
242
235
|
stageHistory: row.stage_history,
|
|
243
236
|
sessions: row.sessions,
|
|
@@ -245,7 +238,6 @@ function toWorkItem(row) {
|
|
|
245
238
|
triageType: row.triage_type ?? null,
|
|
246
239
|
autonomyArmedAt: row.autonomy_armed_at ?? null,
|
|
247
240
|
acceptedAt: row.accepted_at ?? null,
|
|
248
|
-
commentCount: row.comment_count ?? 0,
|
|
249
241
|
revision: row.revision,
|
|
250
242
|
createdBy: row.created_by,
|
|
251
243
|
createdAt: row.created_at,
|
|
@@ -258,6 +250,7 @@ function patchColumns(changes) {
|
|
|
258
250
|
...changes.board !== void 0 ? { board: changes.board } : {},
|
|
259
251
|
...changes.parentWorkItemId !== void 0 ? { parent_work_item_id: changes.parentWorkItemId } : {},
|
|
260
252
|
...changes.title !== void 0 ? { title: changes.title } : {},
|
|
253
|
+
...changes.description !== void 0 ? { description: changes.description } : {},
|
|
261
254
|
...changes.stages !== void 0 ? { stages: changes.stages } : {},
|
|
262
255
|
...changes.stageHistory !== void 0 ? { stage_history: changes.stageHistory } : {},
|
|
263
256
|
...changes.sessions !== void 0 ? { sessions: changes.sessions } : {},
|
|
@@ -364,6 +357,7 @@ function applyUpdate({ current, userId, input, now = /* @__PURE__ */ new Date()
|
|
|
364
357
|
...input.board !== void 0 ? { board: input.board } : {},
|
|
365
358
|
...input.parentWorkItemId !== void 0 ? { parent_work_item_id: input.parentWorkItemId } : {},
|
|
366
359
|
...input.title !== void 0 ? { title: input.title } : {},
|
|
360
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
367
361
|
...input.stages !== void 0 ? {
|
|
368
362
|
stages: input.stages,
|
|
369
363
|
stage_history: applyStageTransition(current.stage_history, current.stages, input.stages, userId, now)
|
|
@@ -779,7 +773,7 @@ function toDeferredDecision(row) {
|
|
|
779
773
|
};
|
|
780
774
|
}
|
|
781
775
|
function attentionReceiptKind(value) {
|
|
782
|
-
if (value === "automation-failed" || value === "automation-proposed" || value === "
|
|
776
|
+
if (value === "automation-failed" || value === "automation-proposed" || value === "agent-waiting") return value;
|
|
783
777
|
throw new Error(`Unsupported attention receipt kind '${String(value)}'.`);
|
|
784
778
|
}
|
|
785
779
|
function attentionReceiptState(value) {
|
|
@@ -939,9 +933,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
939
933
|
FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA,
|
|
940
934
|
FACTORY_BOARD_VERSIONS_SCHEMA,
|
|
941
935
|
...FACTORY_GOVERNANCE_SCHEMAS,
|
|
942
|
-
WORK_ITEM_COMMENTS_SCHEMA,
|
|
943
|
-
WORK_ITEM_COMMENT_MENTIONS_SCHEMA,
|
|
944
|
-
WORK_ITEM_ACTIVITY_SCHEMA,
|
|
945
936
|
FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA
|
|
946
937
|
]);
|
|
947
938
|
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.");
|
|
@@ -1383,7 +1374,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1383
1374
|
/**
|
|
1384
1375
|
* Same rows as {@link list}, but shared with the list cache instead of cloned: the board poll
|
|
1385
1376
|
* reads every card of the project every few seconds, and cloning thousands of rows per poll
|
|
1386
|
-
* costs more than the query the cache saves.
|
|
1377
|
+
* costs more than the query the cache saves. The cached cards are frozen, so a caller that
|
|
1378
|
+
* writes to one throws instead of changing the board every other caller sees.
|
|
1387
1379
|
*/
|
|
1388
1380
|
async listShared({ orgId, factoryProjectId }) {
|
|
1389
1381
|
return (await this.#listCached(orgId, factoryProjectId)).items;
|
|
@@ -1410,7 +1402,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1410
1402
|
items: await inFlight.items,
|
|
1411
1403
|
cached: true
|
|
1412
1404
|
};
|
|
1413
|
-
const read = this.#listWithOps(super.ops, orgId, factoryProjectId);
|
|
1405
|
+
const read = this.#listWithOps(super.ops, orgId, factoryProjectId).then(deepFreeze);
|
|
1414
1406
|
this.#listInFlight.set(key, {
|
|
1415
1407
|
version,
|
|
1416
1408
|
startedAt: Date.now(),
|
|
@@ -1970,28 +1962,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1970
1962
|
});
|
|
1971
1963
|
return Boolean(decision) && parked;
|
|
1972
1964
|
}
|
|
1973
|
-
|
|
1974
|
-
if (identity.kind === "activity") return await ops.findOne("work_item_activity", {
|
|
1975
|
-
work_item_id: identity.sourceId,
|
|
1976
|
-
participant_id: userId,
|
|
1977
|
-
org_id: orgId,
|
|
1978
|
-
factory_project_id: factoryProjectId,
|
|
1979
|
-
occurrence: identity.occurrence
|
|
1980
|
-
}) !== null;
|
|
1981
|
-
if (identity.occurrence !== 0) return false;
|
|
1982
|
-
if (!await ops.findOne("work_item_comment_mentions", {
|
|
1983
|
-
comment_id: identity.sourceId,
|
|
1984
|
-
org_id: orgId,
|
|
1985
|
-
factory_project_id: factoryProjectId,
|
|
1986
|
-
mentioned_kind: "user",
|
|
1987
|
-
mentioned_id: userId
|
|
1988
|
-
})) return false;
|
|
1989
|
-
return await ops.findOne("work_item_comments", {
|
|
1990
|
-
id: identity.sourceId,
|
|
1991
|
-
org_id: orgId,
|
|
1992
|
-
factory_project_id: factoryProjectId,
|
|
1993
|
-
deleted_at: null
|
|
1994
|
-
}) !== null;
|
|
1965
|
+
return true;
|
|
1995
1966
|
}
|
|
1996
1967
|
async #setAttentionReceiptWithOps(ops, { orgId, factoryProjectId, userId, identity, action, now }) {
|
|
1997
1968
|
if (!await this.#attentionSourceIsCurrent(ops, {
|
|
@@ -2600,6 +2571,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2600
2571
|
source_key: externalSourceKey(create.externalSource),
|
|
2601
2572
|
parent_work_item_id: create.parentWorkItemId ?? null,
|
|
2602
2573
|
title: create.title,
|
|
2574
|
+
description: create.description ?? null,
|
|
2603
2575
|
stages: create.stages ?? [],
|
|
2604
2576
|
stage_history: applyStageTransition([], [], create.stages ?? [], input.userId, now),
|
|
2605
2577
|
sessions: stampSessions({ [input.role]: input.session }, input.userId),
|
|
@@ -2741,6 +2713,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2741
2713
|
} : input;
|
|
2742
2714
|
const patch = reuseMode === "non-stage" ? {
|
|
2743
2715
|
title: input.title,
|
|
2716
|
+
description: input.description,
|
|
2744
2717
|
parentWorkItemId: input.parentWorkItemId ?? void 0,
|
|
2745
2718
|
metadata: input.metadata
|
|
2746
2719
|
} : fullPatch;
|
|
@@ -2781,6 +2754,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2781
2754
|
source_key: key,
|
|
2782
2755
|
parent_work_item_id: input.parentWorkItemId ?? null,
|
|
2783
2756
|
title: input.title,
|
|
2757
|
+
description: input.description ?? null,
|
|
2784
2758
|
stages,
|
|
2785
2759
|
stage_history: stages.map((stage) => ({
|
|
2786
2760
|
stage,
|
|
@@ -2888,41 +2862,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2888
2862
|
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 });
|
|
2889
2863
|
}
|
|
2890
2864
|
/**
|
|
2891
|
-
* Feed rows die with their work item: orphan mention rows would keep
|
|
2892
|
-
* projecting attention items that deep-link to a card that no longer exists.
|
|
2893
|
-
*/
|
|
2894
|
-
async #purgeFeedState(ops, { orgId, factoryProjectId, workItemId }) {
|
|
2895
|
-
const where = {
|
|
2896
|
-
org_id: orgId,
|
|
2897
|
-
factory_project_id: factoryProjectId,
|
|
2898
|
-
work_item_id: workItemId
|
|
2899
|
-
};
|
|
2900
|
-
while (true) {
|
|
2901
|
-
const comments = await ops.findMany("work_item_comments", where, { limit: ATTENTION_RECEIPT_QUERY_BATCH_SIZE });
|
|
2902
|
-
if (comments.length === 0) break;
|
|
2903
|
-
const commentIds = comments.map((comment) => comment.id);
|
|
2904
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2905
|
-
org_id: orgId,
|
|
2906
|
-
factory_project_id: factoryProjectId,
|
|
2907
|
-
kind: "mention",
|
|
2908
|
-
source_id: { in: commentIds }
|
|
2909
|
-
});
|
|
2910
|
-
await ops.deleteMany("work_item_comments", {
|
|
2911
|
-
...where,
|
|
2912
|
-
id: { in: commentIds }
|
|
2913
|
-
});
|
|
2914
|
-
if (comments.length < ATTENTION_RECEIPT_QUERY_BATCH_SIZE) break;
|
|
2915
|
-
}
|
|
2916
|
-
await ops.deleteMany("work_item_comment_mentions", where);
|
|
2917
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2918
|
-
org_id: orgId,
|
|
2919
|
-
factory_project_id: factoryProjectId,
|
|
2920
|
-
kind: "activity",
|
|
2921
|
-
source_id: workItemId
|
|
2922
|
-
});
|
|
2923
|
-
await ops.deleteMany("work_item_activity", where);
|
|
2924
|
-
}
|
|
2925
|
-
/**
|
|
2926
2865
|
* Make a session follow a work item. Idempotent: following again keeps the
|
|
2927
2866
|
* first subscription, including its reason (filing beats a later subscribe).
|
|
2928
2867
|
*/
|
|
@@ -2989,11 +2928,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2989
2928
|
const existing = await this.#cards(ops, { transaction: true }).findOne(where);
|
|
2990
2929
|
if (!existing) return null;
|
|
2991
2930
|
if (await this.#cards(ops, { transaction: true }).deleteMany(where) === 0) return null;
|
|
2992
|
-
await this.#purgeFeedState(ops, {
|
|
2993
|
-
orgId,
|
|
2994
|
-
factoryProjectId: existing.factory_project_id,
|
|
2995
|
-
workItemId: id
|
|
2996
|
-
});
|
|
2997
2931
|
await ops.deleteMany(FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA.name, {
|
|
2998
2932
|
org_id: orgId,
|
|
2999
2933
|
work_item_id: id
|
|
@@ -3014,6 +2948,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
3014
2948
|
});
|
|
3015
2949
|
}
|
|
3016
2950
|
};
|
|
3017
|
-
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,
|
|
2951
|
+
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 };
|
|
3018
2952
|
|
|
3019
2953
|
//# sourceMappingURL=base.js.map
|