@mastra/factory 0.28.0-alpha.4 → 0.28.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -28
- 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-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +6 -7
- 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/factory.d.ts +8 -4
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +33 -73
- 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 +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/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/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/run-error-card.js +1 -0
- package/dist/integrations/slack/run-error-card.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/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-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/config.d.ts +7 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +105 -22
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +6 -14
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +4 -2
- 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/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/projects.d.ts +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +1 -1
- 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 +32 -2
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +6 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js.map +1 -1
- 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/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/work-items.d.ts +0 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +0 -1
- 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 +5 -7
- package/dist/rules/dispatcher.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/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/storage/domains/audit/actions.d.ts +1 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +0 -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/work-items/base.d.ts +12 -17
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +42 -117
- 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 +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/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/factory-skills/configure-factory-rules/SKILL.md +3 -3
- package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
- package/factory-skills/factory-gitlab-review/SKILL.md +5 -5
- package/factory-skills/factory-rereview/SKILL.md +70 -24
- package/factory-skills/factory-review/SKILL.md +70 -24
- package/factory-skills/factory-self-review/SKILL.md +5 -6
- package/factory-skills/factory-triage/SKILL.md +11 -22
- package/package.json +8 -8
- 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 -299
- 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,8 +2,7 @@ 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 {
|
|
6
|
-
import { BoardScopes, FACTORY_BOARD_VERSIONS_SCHEMA, bumpBoardVersions, readBoardVersion, trackBoardWrites } from "./board-version.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";
|
|
9
8
|
import { LEGACY_REST_PHASE, LEGACY_WORK_BOARD, readReviewBoardInUse } from "./legacy-review.js";
|
|
@@ -104,21 +103,6 @@ function proposalReceiptFilter(orgId, factoryProjectId, decisionId) {
|
|
|
104
103
|
occurrence: identity.occurrence
|
|
105
104
|
};
|
|
106
105
|
}
|
|
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
106
|
/** Dated by the park itself, so an answer and a new park never share a receipt. */
|
|
123
107
|
function factoryAgentWaitingAttentionIdentity(sessionId, suspendedAt) {
|
|
124
108
|
return {
|
|
@@ -238,6 +222,7 @@ function toWorkItem(row) {
|
|
|
238
222
|
externalSource: row.external_source,
|
|
239
223
|
parentWorkItemId: row.parent_work_item_id,
|
|
240
224
|
title: row.title,
|
|
225
|
+
description: row.description ?? null,
|
|
241
226
|
stages: row.stages,
|
|
242
227
|
stageHistory: row.stage_history,
|
|
243
228
|
sessions: row.sessions,
|
|
@@ -245,7 +230,6 @@ function toWorkItem(row) {
|
|
|
245
230
|
triageType: row.triage_type ?? null,
|
|
246
231
|
autonomyArmedAt: row.autonomy_armed_at ?? null,
|
|
247
232
|
acceptedAt: row.accepted_at ?? null,
|
|
248
|
-
commentCount: row.comment_count ?? 0,
|
|
249
233
|
revision: row.revision,
|
|
250
234
|
createdBy: row.created_by,
|
|
251
235
|
createdAt: row.created_at,
|
|
@@ -258,6 +242,7 @@ function patchColumns(changes) {
|
|
|
258
242
|
...changes.board !== void 0 ? { board: changes.board } : {},
|
|
259
243
|
...changes.parentWorkItemId !== void 0 ? { parent_work_item_id: changes.parentWorkItemId } : {},
|
|
260
244
|
...changes.title !== void 0 ? { title: changes.title } : {},
|
|
245
|
+
...changes.description !== void 0 ? { description: changes.description } : {},
|
|
261
246
|
...changes.stages !== void 0 ? { stages: changes.stages } : {},
|
|
262
247
|
...changes.stageHistory !== void 0 ? { stage_history: changes.stageHistory } : {},
|
|
263
248
|
...changes.sessions !== void 0 ? { sessions: changes.sessions } : {},
|
|
@@ -364,6 +349,7 @@ function applyUpdate({ current, userId, input, now = /* @__PURE__ */ new Date()
|
|
|
364
349
|
...input.board !== void 0 ? { board: input.board } : {},
|
|
365
350
|
...input.parentWorkItemId !== void 0 ? { parent_work_item_id: input.parentWorkItemId } : {},
|
|
366
351
|
...input.title !== void 0 ? { title: input.title } : {},
|
|
352
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
367
353
|
...input.stages !== void 0 ? {
|
|
368
354
|
stages: input.stages,
|
|
369
355
|
stage_history: applyStageTransition(current.stage_history, current.stages, input.stages, userId, now)
|
|
@@ -779,7 +765,7 @@ function toDeferredDecision(row) {
|
|
|
779
765
|
};
|
|
780
766
|
}
|
|
781
767
|
function attentionReceiptKind(value) {
|
|
782
|
-
if (value === "automation-failed" || value === "automation-proposed" || value === "
|
|
768
|
+
if (value === "automation-failed" || value === "automation-proposed" || value === "agent-waiting") return value;
|
|
783
769
|
throw new Error(`Unsupported attention receipt kind '${String(value)}'.`);
|
|
784
770
|
}
|
|
785
771
|
function attentionReceiptState(value) {
|
|
@@ -837,7 +823,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
837
823
|
/** Last full card list per project, valid while the project's board version is unchanged. */
|
|
838
824
|
#listCache = /* @__PURE__ */ new Map();
|
|
839
825
|
#listInFlight = /* @__PURE__ */ new Map();
|
|
840
|
-
#
|
|
826
|
+
#boardChanged = () => {};
|
|
841
827
|
#claimableWorkListeners = /* @__PURE__ */ new Set();
|
|
842
828
|
#isTerminal = () => false;
|
|
843
829
|
#legacyMode = false;
|
|
@@ -881,12 +867,11 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
881
867
|
super("work-items");
|
|
882
868
|
}
|
|
883
869
|
/**
|
|
884
|
-
* Wired once at boot.
|
|
885
|
-
*
|
|
886
|
-
* has to remember, since clients stop polling while their stream is up.
|
|
870
|
+
* Wired once at boot. Fires after a committed write changes what a board shows of a card
|
|
871
|
+
* or a deferred decision, so open boards refetch instead of polling.
|
|
887
872
|
*/
|
|
888
|
-
|
|
889
|
-
this.#
|
|
873
|
+
onBoardChanged(listener) {
|
|
874
|
+
this.#boardChanged = listener;
|
|
890
875
|
}
|
|
891
876
|
/**
|
|
892
877
|
* Fires after any committed write leaves a pending start or deferred decision
|
|
@@ -940,9 +925,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
940
925
|
FACTORY_BOARD_ITEM_TOMBSTONES_SCHEMA,
|
|
941
926
|
FACTORY_BOARD_VERSIONS_SCHEMA,
|
|
942
927
|
...FACTORY_GOVERNANCE_SCHEMAS,
|
|
943
|
-
WORK_ITEM_COMMENTS_SCHEMA,
|
|
944
|
-
WORK_ITEM_COMMENT_MENTIONS_SCHEMA,
|
|
945
|
-
WORK_ITEM_ACTIVITY_SCHEMA,
|
|
946
928
|
FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA
|
|
947
929
|
]);
|
|
948
930
|
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.");
|
|
@@ -1201,15 +1183,31 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1201
1183
|
}
|
|
1202
1184
|
get ops() {
|
|
1203
1185
|
const ops = super.ops;
|
|
1204
|
-
|
|
1186
|
+
const cards = trackBoardWrites(ops, CARD_TABLES, async (scope) => {
|
|
1187
|
+
await bumpBoardVersions(ops, [scope]);
|
|
1188
|
+
this.#announceBoard(scope);
|
|
1189
|
+
});
|
|
1190
|
+
return trackClaimableWrites(trackBoardWrites(cards, DECISION_TABLES, (scope) => this.#announceBoard(scope)), (scope) => this.#claimableWork(scope));
|
|
1191
|
+
}
|
|
1192
|
+
/** Only legacy dry-run writes name no project, and no feed is keyed by org alone. */
|
|
1193
|
+
#announceBoard(scope) {
|
|
1194
|
+
if (scope.factoryProjectId) this.#boardChanged({
|
|
1195
|
+
orgId: scope.orgId,
|
|
1196
|
+
factoryProjectId: scope.factoryProjectId
|
|
1197
|
+
});
|
|
1205
1198
|
}
|
|
1206
|
-
/** `storage.withTransaction`, bumping the board
|
|
1199
|
+
/** `storage.withTransaction`, bumping and announcing the board of every project it wrote once it commits. */
|
|
1207
1200
|
async #withTransaction(fn, options) {
|
|
1208
1201
|
const changed = new BoardScopes();
|
|
1202
|
+
const touched = new BoardScopes();
|
|
1203
|
+
const cardWritten = (scope) => {
|
|
1204
|
+
changed.add(scope);
|
|
1205
|
+
touched.add(scope);
|
|
1206
|
+
};
|
|
1209
1207
|
let queued = /* @__PURE__ */ new Map();
|
|
1210
1208
|
const run = () => {
|
|
1211
1209
|
queued = /* @__PURE__ */ new Map();
|
|
1212
|
-
return this.storage.withTransaction((ops) => fn(trackClaimableWrites(trackBoardWrites(ops,
|
|
1210
|
+
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);
|
|
1213
1211
|
};
|
|
1214
1212
|
let result;
|
|
1215
1213
|
try {
|
|
@@ -1223,6 +1221,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1223
1221
|
} finally {
|
|
1224
1222
|
for (const scope of queued.values()) this.#claimableWork(scope);
|
|
1225
1223
|
}
|
|
1224
|
+
for (const scope of touched.values()) this.#announceBoard(scope);
|
|
1226
1225
|
return result;
|
|
1227
1226
|
}
|
|
1228
1227
|
async #countRows(collection, where) {
|
|
@@ -1954,28 +1953,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
1954
1953
|
});
|
|
1955
1954
|
return Boolean(decision) && parked;
|
|
1956
1955
|
}
|
|
1957
|
-
|
|
1958
|
-
if (identity.kind === "activity") return await ops.findOne("work_item_activity", {
|
|
1959
|
-
work_item_id: identity.sourceId,
|
|
1960
|
-
participant_id: userId,
|
|
1961
|
-
org_id: orgId,
|
|
1962
|
-
factory_project_id: factoryProjectId,
|
|
1963
|
-
occurrence: identity.occurrence
|
|
1964
|
-
}) !== null;
|
|
1965
|
-
if (identity.occurrence !== 0) return false;
|
|
1966
|
-
if (!await ops.findOne("work_item_comment_mentions", {
|
|
1967
|
-
comment_id: identity.sourceId,
|
|
1968
|
-
org_id: orgId,
|
|
1969
|
-
factory_project_id: factoryProjectId,
|
|
1970
|
-
mentioned_kind: "user",
|
|
1971
|
-
mentioned_id: userId
|
|
1972
|
-
})) return false;
|
|
1973
|
-
return await ops.findOne("work_item_comments", {
|
|
1974
|
-
id: identity.sourceId,
|
|
1975
|
-
org_id: orgId,
|
|
1976
|
-
factory_project_id: factoryProjectId,
|
|
1977
|
-
deleted_at: null
|
|
1978
|
-
}) !== null;
|
|
1956
|
+
return true;
|
|
1979
1957
|
}
|
|
1980
1958
|
async #setAttentionReceiptWithOps(ops, { orgId, factoryProjectId, userId, identity, action, now }) {
|
|
1981
1959
|
if (!await this.#attentionSourceIsCurrent(ops, {
|
|
@@ -2075,10 +2053,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2075
2053
|
}
|
|
2076
2054
|
async failDeferredDecision(input) {
|
|
2077
2055
|
const row = await this.#failLease("factory_deferred_decisions", input);
|
|
2078
|
-
|
|
2079
|
-
const record = toDeferredDecision(row);
|
|
2080
|
-
if (input.terminal) this.#attentionChanged(record);
|
|
2081
|
-
return record;
|
|
2056
|
+
return row ? toDeferredDecision(row) : null;
|
|
2082
2057
|
}
|
|
2083
2058
|
/** Park a claimed effect for human approval; the dispatcher never claims `proposed` rows. */
|
|
2084
2059
|
async proposeDeferredDecision(identity, now) {
|
|
@@ -2098,10 +2073,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2098
2073
|
updated_at: now
|
|
2099
2074
|
};
|
|
2100
2075
|
});
|
|
2101
|
-
|
|
2102
|
-
const record = toDeferredDecision(row);
|
|
2103
|
-
this.#attentionChanged(record);
|
|
2104
|
-
return record;
|
|
2076
|
+
return proposed && row ? toDeferredDecision(row) : null;
|
|
2105
2077
|
}
|
|
2106
2078
|
/**
|
|
2107
2079
|
* Release an approved effect back to the dispatcher; only `proposed` rows are
|
|
@@ -2110,7 +2082,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2110
2082
|
* leaving its follow-up work parked for re-approval.
|
|
2111
2083
|
*/
|
|
2112
2084
|
async approveDeferredDecision(orgId, factoryProjectId, decisionId, now, approvedBy) {
|
|
2113
|
-
|
|
2085
|
+
return this.#withTransaction(async (ops) => {
|
|
2114
2086
|
let settled = false;
|
|
2115
2087
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
2116
2088
|
id: decisionId,
|
|
@@ -2137,8 +2109,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2137
2109
|
}, (current) => current.autonomy_armed_at ? null : { autonomy_armed_at: now });
|
|
2138
2110
|
return record;
|
|
2139
2111
|
});
|
|
2140
|
-
if (approved) this.#attentionChanged(approved);
|
|
2141
|
-
return approved;
|
|
2142
2112
|
}
|
|
2143
2113
|
/** Retire a proposal nobody wants: `dismissed` is terminal, so the run never happens. */
|
|
2144
2114
|
async dismissDeferredDecision(orgId, factoryProjectId, decisionId, now) {
|
|
@@ -2186,7 +2156,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2186
2156
|
return superseded;
|
|
2187
2157
|
}
|
|
2188
2158
|
async #settleProposedDecision({ orgId, factoryProjectId, decisionId }, patch) {
|
|
2189
|
-
|
|
2159
|
+
return this.#withTransaction(async (ops) => {
|
|
2190
2160
|
let updated = false;
|
|
2191
2161
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
2192
2162
|
id: decisionId,
|
|
@@ -2201,11 +2171,9 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2201
2171
|
await ops.deleteMany("factory_attention_receipts", proposalReceiptFilter(orgId, factoryProjectId, decisionId));
|
|
2202
2172
|
return toDeferredDecision(row);
|
|
2203
2173
|
});
|
|
2204
|
-
if (settled) this.#attentionChanged(settled);
|
|
2205
|
-
return settled;
|
|
2206
2174
|
}
|
|
2207
2175
|
async #supersedeFailedDecision({ orgId, factoryProjectId, decisionId, now }) {
|
|
2208
|
-
|
|
2176
|
+
return this.#withTransaction(async (ops) => {
|
|
2209
2177
|
let resolved = false;
|
|
2210
2178
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
2211
2179
|
id: decisionId,
|
|
@@ -2229,8 +2197,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2229
2197
|
});
|
|
2230
2198
|
return toDeferredDecision(row);
|
|
2231
2199
|
});
|
|
2232
|
-
if (resolved) this.#attentionChanged(resolved);
|
|
2233
|
-
return resolved;
|
|
2234
2200
|
}
|
|
2235
2201
|
async supersedeTerminalDecisionsForWorkItem(input) {
|
|
2236
2202
|
await this.supersedeDecisionsForWorkItem(input);
|
|
@@ -2286,7 +2252,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2286
2252
|
}
|
|
2287
2253
|
/** Requeue the same idempotent terminal effect; non-failed or non-retryable decisions are never rerun. */
|
|
2288
2254
|
async retryDeferredDecision(orgId, factoryProjectId, decisionId, now) {
|
|
2289
|
-
|
|
2255
|
+
return this.#withTransaction(async (ops) => {
|
|
2290
2256
|
let retried = false;
|
|
2291
2257
|
const row = await ops.updateAtomic("factory_deferred_decisions", {
|
|
2292
2258
|
id: decisionId,
|
|
@@ -2320,8 +2286,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2320
2286
|
});
|
|
2321
2287
|
return toDeferredDecision(row);
|
|
2322
2288
|
});
|
|
2323
|
-
if (retriedRecord) this.#attentionChanged(retriedRecord);
|
|
2324
|
-
return retriedRecord;
|
|
2325
2289
|
}
|
|
2326
2290
|
/** Resolve exact active agent authority; partial session matches never authorize. */
|
|
2327
2291
|
async findActiveRunBinding(address) {
|
|
@@ -2598,6 +2562,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2598
2562
|
source_key: externalSourceKey(create.externalSource),
|
|
2599
2563
|
parent_work_item_id: create.parentWorkItemId ?? null,
|
|
2600
2564
|
title: create.title,
|
|
2565
|
+
description: create.description ?? null,
|
|
2601
2566
|
stages: create.stages ?? [],
|
|
2602
2567
|
stage_history: applyStageTransition([], [], create.stages ?? [], input.userId, now),
|
|
2603
2568
|
sessions: stampSessions({ [input.role]: input.session }, input.userId),
|
|
@@ -2739,6 +2704,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2739
2704
|
} : input;
|
|
2740
2705
|
const patch = reuseMode === "non-stage" ? {
|
|
2741
2706
|
title: input.title,
|
|
2707
|
+
description: input.description,
|
|
2742
2708
|
parentWorkItemId: input.parentWorkItemId ?? void 0,
|
|
2743
2709
|
metadata: input.metadata
|
|
2744
2710
|
} : fullPatch;
|
|
@@ -2779,6 +2745,7 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2779
2745
|
source_key: key,
|
|
2780
2746
|
parent_work_item_id: input.parentWorkItemId ?? null,
|
|
2781
2747
|
title: input.title,
|
|
2748
|
+
description: input.description ?? null,
|
|
2782
2749
|
stages,
|
|
2783
2750
|
stage_history: stages.map((stage) => ({
|
|
2784
2751
|
stage,
|
|
@@ -2886,41 +2853,6 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2886
2853
|
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 });
|
|
2887
2854
|
}
|
|
2888
2855
|
/**
|
|
2889
|
-
* Feed rows die with their work item: orphan mention rows would keep
|
|
2890
|
-
* projecting attention items that deep-link to a card that no longer exists.
|
|
2891
|
-
*/
|
|
2892
|
-
async #purgeFeedState(ops, { orgId, factoryProjectId, workItemId }) {
|
|
2893
|
-
const where = {
|
|
2894
|
-
org_id: orgId,
|
|
2895
|
-
factory_project_id: factoryProjectId,
|
|
2896
|
-
work_item_id: workItemId
|
|
2897
|
-
};
|
|
2898
|
-
while (true) {
|
|
2899
|
-
const comments = await ops.findMany("work_item_comments", where, { limit: ATTENTION_RECEIPT_QUERY_BATCH_SIZE });
|
|
2900
|
-
if (comments.length === 0) break;
|
|
2901
|
-
const commentIds = comments.map((comment) => comment.id);
|
|
2902
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2903
|
-
org_id: orgId,
|
|
2904
|
-
factory_project_id: factoryProjectId,
|
|
2905
|
-
kind: "mention",
|
|
2906
|
-
source_id: { in: commentIds }
|
|
2907
|
-
});
|
|
2908
|
-
await ops.deleteMany("work_item_comments", {
|
|
2909
|
-
...where,
|
|
2910
|
-
id: { in: commentIds }
|
|
2911
|
-
});
|
|
2912
|
-
if (comments.length < ATTENTION_RECEIPT_QUERY_BATCH_SIZE) break;
|
|
2913
|
-
}
|
|
2914
|
-
await ops.deleteMany("work_item_comment_mentions", where);
|
|
2915
|
-
await ops.deleteMany("factory_attention_receipts", {
|
|
2916
|
-
org_id: orgId,
|
|
2917
|
-
factory_project_id: factoryProjectId,
|
|
2918
|
-
kind: "activity",
|
|
2919
|
-
source_id: workItemId
|
|
2920
|
-
});
|
|
2921
|
-
await ops.deleteMany("work_item_activity", where);
|
|
2922
|
-
}
|
|
2923
|
-
/**
|
|
2924
2856
|
* Make a session follow a work item. Idempotent: following again keeps the
|
|
2925
2857
|
* first subscription, including its reason (filing beats a later subscribe).
|
|
2926
2858
|
*/
|
|
@@ -2983,15 +2915,10 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
2983
2915
|
};
|
|
2984
2916
|
const candidate = await this.#cards(this.#db, { transaction: false }).findOne(where);
|
|
2985
2917
|
if (!candidate) return null;
|
|
2986
|
-
|
|
2918
|
+
return this.#withProjectRelationTransaction(orgId, candidate.factory_project_id, async (ops) => {
|
|
2987
2919
|
const existing = await this.#cards(ops, { transaction: true }).findOne(where);
|
|
2988
2920
|
if (!existing) return null;
|
|
2989
2921
|
if (await this.#cards(ops, { transaction: true }).deleteMany(where) === 0) return null;
|
|
2990
|
-
await this.#purgeFeedState(ops, {
|
|
2991
|
-
orgId,
|
|
2992
|
-
factoryProjectId: existing.factory_project_id,
|
|
2993
|
-
workItemId: id
|
|
2994
|
-
});
|
|
2995
2922
|
await ops.deleteMany(FACTORY_WORK_ITEM_SUBSCRIPTIONS_SCHEMA.name, {
|
|
2996
2923
|
org_id: orgId,
|
|
2997
2924
|
work_item_id: id
|
|
@@ -3010,10 +2937,8 @@ var WorkItemsStorage = class extends FactoryStorageDomain {
|
|
|
3010
2937
|
});
|
|
3011
2938
|
return toWorkItem(existing);
|
|
3012
2939
|
});
|
|
3013
|
-
if (removed) this.#attentionChanged(removed);
|
|
3014
|
-
return removed;
|
|
3015
2940
|
}
|
|
3016
2941
|
};
|
|
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,
|
|
2942
|
+
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
2943
|
|
|
3019
2944
|
//# sourceMappingURL=base.js.map
|