@shipfox/api-workflows 13.1.0 → 15.0.0
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +61 -0
- package/README.md +12 -5
- package/dist/core/checkout.d.ts +4 -2
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js +7 -2
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/job.d.ts +1 -1
- package/dist/core/entities/job.d.ts.map +1 -1
- package/dist/core/entities/job.js.map +1 -1
- package/dist/core/entities/workflow-run.d.ts +25 -6
- package/dist/core/entities/workflow-run.d.ts.map +1 -1
- package/dist/core/entities/workflow-run.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/run-workflow.d.ts +26 -1
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js +27 -1
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/db/db.d.ts +72 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/schema/workflow-runs.d.ts +45 -1
- package/dist/db/schema/workflow-runs.d.ts.map +1 -1
- package/dist/db/schema/workflow-runs.js +42 -1
- package/dist/db/schema/workflow-runs.js.map +1 -1
- package/dist/db/workflow-runs/jobs.d.ts +3 -1
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
- package/dist/db/workflow-runs/jobs.js +12 -3
- package/dist/db/workflow-runs/jobs.js.map +1 -1
- package/dist/db/workflow-runs/queries.d.ts +3 -2
- package/dist/db/workflow-runs/queries.d.ts.map +1 -1
- package/dist/db/workflow-runs/queries.js +3 -0
- package/dist/db/workflow-runs/queries.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +4 -1
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +14 -1
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -1
- package/dist/presentation/dto/workflow-run.js +14 -0
- package/dist/presentation/dto/workflow-run.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +1 -0
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +41 -4
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +2 -1
- package/dist/presentation/routes/checkout-token.js.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.js +2 -1
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
- package/dist/presentation/routes/leased-step.d.ts +3 -1
- package/dist/presentation/routes/leased-step.d.ts.map +1 -1
- package/dist/presentation/routes/leased-step.js +2 -1
- package/dist/presentation/routes/leased-step.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js +2 -1
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0004_dev_run_origin.sql +12 -0
- package/drizzle/meta/0004_snapshot.json +1773 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +16 -16
- package/src/core/checkout.test.ts +198 -1
- package/src/core/checkout.ts +18 -5
- package/src/core/entities/job.ts +1 -1
- package/src/core/entities/workflow-run.ts +26 -6
- package/src/core/index.ts +2 -2
- package/src/core/job-transition/decide-job-activation.test.ts +2 -0
- package/src/core/run-workflow.test.ts +151 -3
- package/src/core/run-workflow.ts +59 -3
- package/src/core/workflow-run-creation.test.ts +2 -0
- package/src/db/job-listeners.test.ts +17 -0
- package/src/db/schema/workflow-runs.ts +58 -0
- package/src/db/workflow-runs/jobs.ts +17 -3
- package/src/db/workflow-runs/queries.ts +6 -1
- package/src/db/workflow-runs/run-create.test.ts +87 -0
- package/src/db/workflow-runs/run-create.ts +23 -1
- package/src/presentation/dto/workflow-run.ts +23 -1
- package/src/presentation/inter-module.test.ts +131 -1
- package/src/presentation/inter-module.ts +48 -3
- package/src/presentation/routes/checkout-token.test.ts +45 -0
- package/src/presentation/routes/checkout-token.ts +2 -1
- package/src/presentation/routes/get-run-aggregates.test.ts +56 -0
- package/src/presentation/routes/get-run-aggregates.ts +2 -0
- package/src/presentation/routes/get-step-secrets.test.ts +1 -0
- package/src/presentation/routes/leased-step.ts +7 -1
- package/src/presentation/routes/list-runs.test.ts +152 -0
- package/src/presentation/routes/list-runs.ts +2 -0
- package/test/factories/workflow-run.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/dist/db/db.d.ts
CHANGED
|
@@ -140,6 +140,42 @@ export declare const schema: {
|
|
|
140
140
|
identity: undefined;
|
|
141
141
|
generated: undefined;
|
|
142
142
|
}, {}, {}>;
|
|
143
|
+
origin: import("drizzle-orm/pg-core").PgColumn<{
|
|
144
|
+
name: "origin";
|
|
145
|
+
tableName: "workflow_runs";
|
|
146
|
+
dataType: "string";
|
|
147
|
+
columnType: "PgText";
|
|
148
|
+
data: string;
|
|
149
|
+
driverParam: string;
|
|
150
|
+
notNull: true;
|
|
151
|
+
hasDefault: true;
|
|
152
|
+
isPrimaryKey: false;
|
|
153
|
+
isAutoincrement: false;
|
|
154
|
+
hasRuntimeDefault: false;
|
|
155
|
+
enumValues: [string, ...string[]];
|
|
156
|
+
baseColumn: never;
|
|
157
|
+
identity: undefined;
|
|
158
|
+
generated: undefined;
|
|
159
|
+
}, {}, {}>;
|
|
160
|
+
devSource: import("drizzle-orm/pg-core").PgColumn<{
|
|
161
|
+
name: "dev_source";
|
|
162
|
+
tableName: "workflow_runs";
|
|
163
|
+
dataType: "json";
|
|
164
|
+
columnType: "PgJsonb";
|
|
165
|
+
data: import("./schema/workflow-runs.js").WorkflowRunDevSourceDb;
|
|
166
|
+
driverParam: unknown;
|
|
167
|
+
notNull: false;
|
|
168
|
+
hasDefault: false;
|
|
169
|
+
isPrimaryKey: false;
|
|
170
|
+
isAutoincrement: false;
|
|
171
|
+
hasRuntimeDefault: false;
|
|
172
|
+
enumValues: undefined;
|
|
173
|
+
baseColumn: never;
|
|
174
|
+
identity: undefined;
|
|
175
|
+
generated: undefined;
|
|
176
|
+
}, {}, {
|
|
177
|
+
$type: import("./schema/workflow-runs.js").WorkflowRunDevSourceDb;
|
|
178
|
+
}>;
|
|
143
179
|
currentAttempt: import("drizzle-orm/pg-core").PgColumn<{
|
|
144
180
|
name: "current_attempt";
|
|
145
181
|
tableName: "workflow_runs";
|
|
@@ -2774,6 +2810,42 @@ export declare function db(): NodePgDatabase<{
|
|
|
2774
2810
|
identity: undefined;
|
|
2775
2811
|
generated: undefined;
|
|
2776
2812
|
}, {}, {}>;
|
|
2813
|
+
origin: import("drizzle-orm/pg-core").PgColumn<{
|
|
2814
|
+
name: "origin";
|
|
2815
|
+
tableName: "workflow_runs";
|
|
2816
|
+
dataType: "string";
|
|
2817
|
+
columnType: "PgText";
|
|
2818
|
+
data: string;
|
|
2819
|
+
driverParam: string;
|
|
2820
|
+
notNull: true;
|
|
2821
|
+
hasDefault: true;
|
|
2822
|
+
isPrimaryKey: false;
|
|
2823
|
+
isAutoincrement: false;
|
|
2824
|
+
hasRuntimeDefault: false;
|
|
2825
|
+
enumValues: [string, ...string[]];
|
|
2826
|
+
baseColumn: never;
|
|
2827
|
+
identity: undefined;
|
|
2828
|
+
generated: undefined;
|
|
2829
|
+
}, {}, {}>;
|
|
2830
|
+
devSource: import("drizzle-orm/pg-core").PgColumn<{
|
|
2831
|
+
name: "dev_source";
|
|
2832
|
+
tableName: "workflow_runs";
|
|
2833
|
+
dataType: "json";
|
|
2834
|
+
columnType: "PgJsonb";
|
|
2835
|
+
data: import("./schema/workflow-runs.js").WorkflowRunDevSourceDb;
|
|
2836
|
+
driverParam: unknown;
|
|
2837
|
+
notNull: false;
|
|
2838
|
+
hasDefault: false;
|
|
2839
|
+
isPrimaryKey: false;
|
|
2840
|
+
isAutoincrement: false;
|
|
2841
|
+
hasRuntimeDefault: false;
|
|
2842
|
+
enumValues: undefined;
|
|
2843
|
+
baseColumn: never;
|
|
2844
|
+
identity: undefined;
|
|
2845
|
+
generated: undefined;
|
|
2846
|
+
}, {}, {
|
|
2847
|
+
$type: import("./schema/workflow-runs.js").WorkflowRunDevSourceDb;
|
|
2848
|
+
}>;
|
|
2777
2849
|
currentAttempt: import("drizzle-orm/pg-core").PgColumn<{
|
|
2778
2850
|
name: "current_attempt";
|
|
2779
2851
|
tableName: "workflow_runs";
|
package/dist/db/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAYnE,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAYnE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAI5F,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEzE"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type { TriggerPayload, WorkflowRun, WorkflowRunTriggerReference, WorkflowSourceSnapshot } from '#core/entities/workflow-run.js';
|
|
1
|
+
import type { TriggerPayload, WorkflowRun, WorkflowRunOriginState, WorkflowRunTriggerReference, WorkflowSourceSnapshot } from '#core/entities/workflow-run.js';
|
|
2
2
|
export declare const workflowRunStatusEnum: import("drizzle-orm/pg-core").PgEnum<["pending", "running", "succeeded", "failed", "cancelled"]>;
|
|
3
3
|
export declare const workflowRunRerunModeEnum: import("drizzle-orm/pg-core").PgEnum<["all", "failed"]>;
|
|
4
|
+
export interface WorkflowRunDevSourceDb {
|
|
5
|
+
ref: string;
|
|
6
|
+
commit: string;
|
|
7
|
+
config_path: string;
|
|
8
|
+
initiated_by_user_id: string;
|
|
9
|
+
replay_of_event_id: string | null;
|
|
10
|
+
}
|
|
4
11
|
export declare const workflowRuns: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
5
12
|
name: "workflow_runs";
|
|
6
13
|
schema: undefined;
|
|
@@ -141,6 +148,42 @@ export declare const workflowRuns: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
141
148
|
identity: undefined;
|
|
142
149
|
generated: undefined;
|
|
143
150
|
}, {}, {}>;
|
|
151
|
+
origin: import("drizzle-orm/pg-core").PgColumn<{
|
|
152
|
+
name: "origin";
|
|
153
|
+
tableName: "workflow_runs";
|
|
154
|
+
dataType: "string";
|
|
155
|
+
columnType: "PgText";
|
|
156
|
+
data: string;
|
|
157
|
+
driverParam: string;
|
|
158
|
+
notNull: true;
|
|
159
|
+
hasDefault: true;
|
|
160
|
+
isPrimaryKey: false;
|
|
161
|
+
isAutoincrement: false;
|
|
162
|
+
hasRuntimeDefault: false;
|
|
163
|
+
enumValues: [string, ...string[]];
|
|
164
|
+
baseColumn: never;
|
|
165
|
+
identity: undefined;
|
|
166
|
+
generated: undefined;
|
|
167
|
+
}, {}, {}>;
|
|
168
|
+
devSource: import("drizzle-orm/pg-core").PgColumn<{
|
|
169
|
+
name: "dev_source";
|
|
170
|
+
tableName: "workflow_runs";
|
|
171
|
+
dataType: "json";
|
|
172
|
+
columnType: "PgJsonb";
|
|
173
|
+
data: WorkflowRunDevSourceDb;
|
|
174
|
+
driverParam: unknown;
|
|
175
|
+
notNull: false;
|
|
176
|
+
hasDefault: false;
|
|
177
|
+
isPrimaryKey: false;
|
|
178
|
+
isAutoincrement: false;
|
|
179
|
+
hasRuntimeDefault: false;
|
|
180
|
+
enumValues: undefined;
|
|
181
|
+
baseColumn: never;
|
|
182
|
+
identity: undefined;
|
|
183
|
+
generated: undefined;
|
|
184
|
+
}, {}, {
|
|
185
|
+
$type: WorkflowRunDevSourceDb;
|
|
186
|
+
}>;
|
|
144
187
|
currentAttempt: import("drizzle-orm/pg-core").PgColumn<{
|
|
145
188
|
name: "current_attempt";
|
|
146
189
|
tableName: "workflow_runs";
|
|
@@ -410,4 +453,5 @@ export declare const workflowRuns: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
410
453
|
export type WorkflowRunDb = typeof workflowRuns.$inferSelect;
|
|
411
454
|
export type WorkflowRunCreateDb = typeof workflowRuns.$inferInsert;
|
|
412
455
|
export declare function toWorkflowRun(row: WorkflowRunDb): WorkflowRun;
|
|
456
|
+
export declare function toWorkflowRunOriginState(row: Pick<WorkflowRunDb, 'origin' | 'devSource'>): WorkflowRunOriginState;
|
|
413
457
|
//# sourceMappingURL=workflow-runs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runs.d.ts","sourceRoot":"","sources":["../../../src/db/schema/workflow-runs.ts"],"names":[],"mappings":"AAe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;;;;;EA2ExB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;AAC7D,MAAM,MAAM,mBAAmB,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;AAEnE,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,WAAW,CA6B7D;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,WAAW,CAAC,GAC/C,sBAAsB,CAuBxB"}
|
|
@@ -23,6 +23,8 @@ export const workflowRuns = pgTable('workflow_runs', {
|
|
|
23
23
|
name: text('name'),
|
|
24
24
|
workflowName: text('workflow_name').notNull(),
|
|
25
25
|
status: workflowRunStatusEnum('status').notNull().default('pending'),
|
|
26
|
+
origin: text('origin').notNull().default('synced'),
|
|
27
|
+
devSource: jsonb('dev_source').$type(),
|
|
26
28
|
currentAttempt: integer('current_attempt').notNull().default(1),
|
|
27
29
|
triggerProvider: text('trigger_provider'),
|
|
28
30
|
triggerSource: text('trigger_source').notNull(),
|
|
@@ -52,6 +54,7 @@ export const workflowRuns = pgTable('workflow_runs', {
|
|
|
52
54
|
uniqueIndex('workflows_wr_trigger_idempotency_key_unique').on(table.triggerIdempotencyKey),
|
|
53
55
|
uniqueIndex('workflows_wr_definition_number_unique').on(table.definitionId, table.number),
|
|
54
56
|
index('workflows_wr_project_created_id_idx').on(table.projectId, table.createdAt, table.id),
|
|
57
|
+
index('workflows_wr_project_origin_created_id_idx').on(table.projectId, table.origin, table.createdAt, table.id),
|
|
55
58
|
index('workflows_wr_project_status_created_id_idx').on(table.projectId, table.status, table.createdAt, table.id),
|
|
56
59
|
index('workflows_wr_project_definition_created_id_idx').on(table.projectId, table.definitionId, table.createdAt, table.id),
|
|
57
60
|
index('workflows_wr_project_trigger_created_id_idx').on(table.projectId, table.triggerSource, table.createdAt, table.id),
|
|
@@ -59,9 +62,19 @@ export const workflowRuns = pgTable('workflow_runs', {
|
|
|
59
62
|
// Prometheus scrape. Indexes only active rows so the count stays cheap as the
|
|
60
63
|
// historical table grows.
|
|
61
64
|
index('workflows_wr_running_idx').on(table.status).where(sql`${table.status} = 'running'`),
|
|
62
|
-
check('workflows_wr_current_attempt_positive_ck', sql`${table.currentAttempt} > 0`)
|
|
65
|
+
check('workflows_wr_current_attempt_positive_ck', sql`${table.currentAttempt} > 0`),
|
|
66
|
+
check('workflows_wr_origin_ck', sql`${table.origin} in ('synced', 'dev')`),
|
|
67
|
+
check('workflows_wr_dev_source_ck', sql`(
|
|
68
|
+
(${table.origin} = 'synced' and ${table.devSource} is null)
|
|
69
|
+
or (
|
|
70
|
+
${table.origin} = 'dev'
|
|
71
|
+
and ${table.devSource} is not null
|
|
72
|
+
and jsonb_typeof(${table.devSource}) = 'object'
|
|
73
|
+
)
|
|
74
|
+
)`)
|
|
63
75
|
]);
|
|
64
76
|
export function toWorkflowRun(row) {
|
|
77
|
+
const originState = toWorkflowRunOriginState(row);
|
|
65
78
|
return {
|
|
66
79
|
id: row.id,
|
|
67
80
|
workspaceId: row.workspaceId,
|
|
@@ -72,6 +85,7 @@ export function toWorkflowRun(row) {
|
|
|
72
85
|
workflowName: row.workflowName,
|
|
73
86
|
nameOverride: row.name,
|
|
74
87
|
status: row.status,
|
|
88
|
+
...originState,
|
|
75
89
|
currentAttempt: row.currentAttempt,
|
|
76
90
|
triggerProvider: row.triggerProvider,
|
|
77
91
|
triggerSource: row.triggerSource,
|
|
@@ -89,5 +103,32 @@ export function toWorkflowRun(row) {
|
|
|
89
103
|
finishedAt: row.finishedAt
|
|
90
104
|
};
|
|
91
105
|
}
|
|
106
|
+
export function toWorkflowRunOriginState(row) {
|
|
107
|
+
if (row.origin === 'synced') {
|
|
108
|
+
if (row.devSource !== null) {
|
|
109
|
+
throw new Error(`Synced workflow run has unexpected dev source`);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
origin: 'synced',
|
|
113
|
+
devSource: null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (row.origin !== 'dev') {
|
|
117
|
+
throw new Error(`Unknown workflow run origin: ${row.origin}`);
|
|
118
|
+
}
|
|
119
|
+
if (!row.devSource) {
|
|
120
|
+
throw new Error('Dev workflow run is missing its source');
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
origin: 'dev',
|
|
124
|
+
devSource: {
|
|
125
|
+
ref: row.devSource.ref,
|
|
126
|
+
commit: row.devSource.commit,
|
|
127
|
+
configPath: row.devSource.config_path,
|
|
128
|
+
initiatedByUserId: row.devSource.initiated_by_user_id,
|
|
129
|
+
replayOfEventId: row.devSource.replay_of_event_id
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
92
133
|
|
|
93
134
|
//# sourceMappingURL=workflow-runs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/schema/workflow-runs.ts"],"sourcesContent":["import {DEFAULT_RUN_TIMEOUT_MS} from '@shipfox/api-definitions-dto';\nimport {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {\n bigint,\n check,\n index,\n integer,\n jsonb,\n pgEnum,\n text,\n timestamp,\n uniqueIndex,\n uuid,\n} from 'drizzle-orm/pg-core';\nimport type {\n TriggerPayload,\n WorkflowRun,\n WorkflowRunTriggerReference,\n WorkflowSourceSnapshot,\n} from '#core/entities/workflow-run.js';\nimport {pgTable} from './common.js';\n\nexport const workflowRunStatusEnum = pgEnum('workflows_run_status', [\n 'pending',\n 'running',\n 'succeeded',\n 'failed',\n 'cancelled',\n]);\n\nexport const workflowRunRerunModeEnum = pgEnum('workflows_rerun_mode', ['all', 'failed']);\n\nexport const workflowRuns = pgTable(\n 'workflow_runs',\n {\n id: uuidv7PrimaryKey(),\n workspaceId: uuid('workspace_id').notNull(),\n projectId: uuid('project_id').notNull(),\n definitionId: uuid('definition_id').notNull(),\n number: integer('number').notNull(),\n name: text('name'),\n workflowName: text('workflow_name').notNull(),\n status: workflowRunStatusEnum('status').notNull().default('pending'),\n currentAttempt: integer('current_attempt').notNull().default(1),\n triggerProvider: text('trigger_provider'),\n triggerSource: text('trigger_source').notNull(),\n triggerEvent: text('trigger_event').notNull(),\n triggerPayload: jsonb('trigger_payload').notNull().$type<TriggerPayload>(),\n triggerReference: jsonb('trigger_reference').$type<WorkflowRunTriggerReference>(),\n inputs: jsonb('inputs').$type<Record<string, unknown>>(),\n sourceSnapshot: jsonb('source_snapshot').$type<WorkflowSourceSnapshot>(),\n triggerIdempotencyKey: text('trigger_idempotency_key'),\n timeoutMs: bigint('timeout_ms', {mode: 'number'}).notNull().default(DEFAULT_RUN_TIMEOUT_MS),\n version: integer('version').notNull().default(1),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n startedAt: timestamp('started_at', {withTimezone: true}),\n finishedAt: timestamp('finished_at', {withTimezone: true}),\n },\n (table) => [\n uniqueIndex('workflows_wr_trigger_idempotency_key_unique').on(table.triggerIdempotencyKey),\n uniqueIndex('workflows_wr_definition_number_unique').on(table.definitionId, table.number),\n index('workflows_wr_project_created_id_idx').on(table.projectId, table.createdAt, table.id),\n index('workflows_wr_project_status_created_id_idx').on(\n table.projectId,\n table.status,\n table.createdAt,\n table.id,\n ),\n index('workflows_wr_project_definition_created_id_idx').on(\n table.projectId,\n table.definitionId,\n table.createdAt,\n table.id,\n ),\n index('workflows_wr_project_trigger_created_id_idx').on(\n table.projectId,\n table.triggerSource,\n table.createdAt,\n table.id,\n ),\n // Partial index backing the running-runs depth gauge, which counts on every\n // Prometheus scrape. Indexes only active rows so the count stays cheap as the\n // historical table grows.\n index('workflows_wr_running_idx').on(table.status).where(sql`${table.status} = 'running'`),\n check('workflows_wr_current_attempt_positive_ck', sql`${table.currentAttempt} > 0`),\n ],\n);\n\nexport type WorkflowRunDb = typeof workflowRuns.$inferSelect;\nexport type WorkflowRunCreateDb = typeof workflowRuns.$inferInsert;\n\nexport function toWorkflowRun(row: WorkflowRunDb): WorkflowRun {\n return {\n id: row.id,\n workspaceId: row.workspaceId,\n projectId: row.projectId,\n definitionId: row.definitionId,\n number: row.number,\n name: row.name ?? row.workflowName,\n workflowName: row.workflowName,\n nameOverride: row.name,\n status: row.status,\n currentAttempt: row.currentAttempt,\n triggerProvider: row.triggerProvider,\n triggerSource: row.triggerSource,\n triggerEvent: row.triggerEvent,\n triggerPayload: row.triggerPayload as TriggerPayload,\n triggerReference: row.triggerReference ?? null,\n inputs: row.inputs ?? null,\n sourceSnapshot: row.sourceSnapshot ?? null,\n triggerIdempotencyKey: row.triggerIdempotencyKey,\n timeoutMs: row.timeoutMs,\n version: row.version,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n startedAt: row.startedAt,\n finishedAt: row.finishedAt,\n };\n}\n"],"names":["DEFAULT_RUN_TIMEOUT_MS","uuidv7PrimaryKey","sql","bigint","check","index","integer","jsonb","pgEnum","text","timestamp","uniqueIndex","uuid","pgTable","workflowRunStatusEnum","workflowRunRerunModeEnum","workflowRuns","id","workspaceId","notNull","projectId","definitionId","number","name","workflowName","status","default","currentAttempt","triggerProvider","triggerSource","triggerEvent","triggerPayload","$type","triggerReference","inputs","sourceSnapshot","triggerIdempotencyKey","timeoutMs","mode","version","createdAt","withTimezone","defaultNow","updatedAt","startedAt","finishedAt","table","on","where","toWorkflowRun","row","nameOverride"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,+BAA+B;AACpE,SAAQC,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SACEC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,WAAW,EACXC,IAAI,QACC,sBAAsB;AAO7B,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,wBAAwBN,OAAO,wBAAwB;IAClE;IACA;IAC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oB,IAAIpB,YAAY;QAC9BC,gBAAgBmB,IAAInB,cAAc;QAClCE,kBAAkBiB,IAAIjB,gBAAgB,IAAI;QAC1CC,QAAQgB,IAAIhB,MAAM,IAAI;QACtBC,gBAAgBe,IAAIf,cAAc,IAAI;QACtCC,uBAAuBc,IAAId,qBAAqB;QAChDC,WAAWa,IAAIb,SAAS;QACxBE,SAASW,IAAIX,OAAO;QACpBC,WAAWU,IAAIV,SAAS;QACxBG,WAAWO,IAAIP,SAAS;QACxBC,WAAWM,IAAIN,SAAS;QACxBC,YAAYK,IAAIL,UAAU;IAC5B;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/workflow-runs.ts"],"sourcesContent":["import {DEFAULT_RUN_TIMEOUT_MS} from '@shipfox/api-definitions-dto';\nimport {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {\n bigint,\n check,\n index,\n integer,\n jsonb,\n pgEnum,\n text,\n timestamp,\n uniqueIndex,\n uuid,\n} from 'drizzle-orm/pg-core';\nimport type {\n TriggerPayload,\n WorkflowRun,\n WorkflowRunOriginState,\n WorkflowRunTriggerReference,\n WorkflowSourceSnapshot,\n} from '#core/entities/workflow-run.js';\nimport {pgTable} from './common.js';\n\nexport const workflowRunStatusEnum = pgEnum('workflows_run_status', [\n 'pending',\n 'running',\n 'succeeded',\n 'failed',\n 'cancelled',\n]);\n\nexport const workflowRunRerunModeEnum = pgEnum('workflows_rerun_mode', ['all', 'failed']);\n\nexport interface WorkflowRunDevSourceDb {\n ref: string;\n commit: string;\n config_path: string;\n initiated_by_user_id: string;\n replay_of_event_id: string | null;\n}\n\nexport const workflowRuns = pgTable(\n 'workflow_runs',\n {\n id: uuidv7PrimaryKey(),\n workspaceId: uuid('workspace_id').notNull(),\n projectId: uuid('project_id').notNull(),\n definitionId: uuid('definition_id').notNull(),\n number: integer('number').notNull(),\n name: text('name'),\n workflowName: text('workflow_name').notNull(),\n status: workflowRunStatusEnum('status').notNull().default('pending'),\n origin: text('origin').notNull().default('synced'),\n devSource: jsonb('dev_source').$type<WorkflowRunDevSourceDb>(),\n currentAttempt: integer('current_attempt').notNull().default(1),\n triggerProvider: text('trigger_provider'),\n triggerSource: text('trigger_source').notNull(),\n triggerEvent: text('trigger_event').notNull(),\n triggerPayload: jsonb('trigger_payload').notNull().$type<TriggerPayload>(),\n triggerReference: jsonb('trigger_reference').$type<WorkflowRunTriggerReference>(),\n inputs: jsonb('inputs').$type<Record<string, unknown>>(),\n sourceSnapshot: jsonb('source_snapshot').$type<WorkflowSourceSnapshot>(),\n triggerIdempotencyKey: text('trigger_idempotency_key'),\n timeoutMs: bigint('timeout_ms', {mode: 'number'}).notNull().default(DEFAULT_RUN_TIMEOUT_MS),\n version: integer('version').notNull().default(1),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n startedAt: timestamp('started_at', {withTimezone: true}),\n finishedAt: timestamp('finished_at', {withTimezone: true}),\n },\n (table) => [\n uniqueIndex('workflows_wr_trigger_idempotency_key_unique').on(table.triggerIdempotencyKey),\n uniqueIndex('workflows_wr_definition_number_unique').on(table.definitionId, table.number),\n index('workflows_wr_project_created_id_idx').on(table.projectId, table.createdAt, table.id),\n index('workflows_wr_project_origin_created_id_idx').on(\n table.projectId,\n table.origin,\n table.createdAt,\n table.id,\n ),\n index('workflows_wr_project_status_created_id_idx').on(\n table.projectId,\n table.status,\n table.createdAt,\n table.id,\n ),\n index('workflows_wr_project_definition_created_id_idx').on(\n table.projectId,\n table.definitionId,\n table.createdAt,\n table.id,\n ),\n index('workflows_wr_project_trigger_created_id_idx').on(\n table.projectId,\n table.triggerSource,\n table.createdAt,\n table.id,\n ),\n // Partial index backing the running-runs depth gauge, which counts on every\n // Prometheus scrape. Indexes only active rows so the count stays cheap as the\n // historical table grows.\n index('workflows_wr_running_idx').on(table.status).where(sql`${table.status} = 'running'`),\n check('workflows_wr_current_attempt_positive_ck', sql`${table.currentAttempt} > 0`),\n check('workflows_wr_origin_ck', sql`${table.origin} in ('synced', 'dev')`),\n check(\n 'workflows_wr_dev_source_ck',\n sql`(\n (${table.origin} = 'synced' and ${table.devSource} is null)\n or (\n ${table.origin} = 'dev'\n and ${table.devSource} is not null\n and jsonb_typeof(${table.devSource}) = 'object'\n )\n )`,\n ),\n ],\n);\n\nexport type WorkflowRunDb = typeof workflowRuns.$inferSelect;\nexport type WorkflowRunCreateDb = typeof workflowRuns.$inferInsert;\n\nexport function toWorkflowRun(row: WorkflowRunDb): WorkflowRun {\n const originState = toWorkflowRunOriginState(row);\n return {\n id: row.id,\n workspaceId: row.workspaceId,\n projectId: row.projectId,\n definitionId: row.definitionId,\n number: row.number,\n name: row.name ?? row.workflowName,\n workflowName: row.workflowName,\n nameOverride: row.name,\n status: row.status,\n ...originState,\n currentAttempt: row.currentAttempt,\n triggerProvider: row.triggerProvider,\n triggerSource: row.triggerSource,\n triggerEvent: row.triggerEvent,\n triggerPayload: row.triggerPayload as TriggerPayload,\n triggerReference: row.triggerReference ?? null,\n inputs: row.inputs ?? null,\n sourceSnapshot: row.sourceSnapshot ?? null,\n triggerIdempotencyKey: row.triggerIdempotencyKey,\n timeoutMs: row.timeoutMs,\n version: row.version,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n startedAt: row.startedAt,\n finishedAt: row.finishedAt,\n };\n}\n\nexport function toWorkflowRunOriginState(\n row: Pick<WorkflowRunDb, 'origin' | 'devSource'>,\n): WorkflowRunOriginState {\n if (row.origin === 'synced') {\n if (row.devSource !== null) {\n throw new Error(`Synced workflow run has unexpected dev source`);\n }\n return {origin: 'synced', devSource: null};\n }\n if (row.origin !== 'dev') {\n throw new Error(`Unknown workflow run origin: ${row.origin}`);\n }\n if (!row.devSource) {\n throw new Error('Dev workflow run is missing its source');\n }\n return {\n origin: 'dev',\n devSource: {\n ref: row.devSource.ref,\n commit: row.devSource.commit,\n configPath: row.devSource.config_path,\n initiatedByUserId: row.devSource.initiated_by_user_id,\n replayOfEventId: row.devSource.replay_of_event_id,\n },\n };\n}\n"],"names":["DEFAULT_RUN_TIMEOUT_MS","uuidv7PrimaryKey","sql","bigint","check","index","integer","jsonb","pgEnum","text","timestamp","uniqueIndex","uuid","pgTable","workflowRunStatusEnum","workflowRunRerunModeEnum","workflowRuns","id","workspaceId","notNull","projectId","definitionId","number","name","workflowName","status","default","origin","devSource","$type","currentAttempt","triggerProvider","triggerSource","triggerEvent","triggerPayload","triggerReference","inputs","sourceSnapshot","triggerIdempotencyKey","timeoutMs","mode","version","createdAt","withTimezone","defaultNow","updatedAt","startedAt","finishedAt","table","on","where","toWorkflowRun","row","originState","toWorkflowRunOriginState","nameOverride","Error","ref","commit","configPath","config_path","initiatedByUserId","initiated_by_user_id","replayOfEventId","replay_of_event_id"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,+BAA+B;AACpE,SAAQC,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SACEC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,WAAW,EACXC,IAAI,QACC,sBAAsB;AAQ7B,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,wBAAwBN,OAAO,wBAAwB;IAClE;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMO,2BAA2BP,OAAO,wBAAwB;IAAC;IAAO;CAAS,EAAE;AAU1F,OAAO,MAAMQ,eAAeH,QAC1B,iBACA;IACEI,IAAIhB;IACJiB,aAAaN,KAAK,gBAAgBO,OAAO;IACzCC,WAAWR,KAAK,cAAcO,OAAO;IACrCE,cAAcT,KAAK,iBAAiBO,OAAO;IAC3CG,QAAQhB,QAAQ,UAAUa,OAAO;IACjCI,MAAMd,KAAK;IACXe,cAAcf,KAAK,iBAAiBU,OAAO;IAC3CM,QAAQX,sBAAsB,UA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;QACnD;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Job, type JobStatus, type JobStatusReason } from '#core/entities/job.js';
|
|
2
2
|
import type { PersistedEvaluationTraceEntry } from '#core/entities/step.js';
|
|
3
|
-
import type { WorkflowRunTriggerReference } from '#core/entities/workflow-run.js';
|
|
3
|
+
import type { WorkflowRunOriginState, WorkflowRunTriggerReference } from '#core/entities/workflow-run.js';
|
|
4
4
|
import { type DeriveJobSuccessResult, deriveJobSuccess } from '#core/job-transition/index.js';
|
|
5
5
|
import type { JobContextInput } from '#core/step-config/assemble-run-context.js';
|
|
6
6
|
import type { RuntimeCompletionStatus } from '#core/workflow-scheduling/runtime-dag.js';
|
|
@@ -12,6 +12,8 @@ export interface JobScope {
|
|
|
12
12
|
workspaceId: string;
|
|
13
13
|
projectId: string;
|
|
14
14
|
triggerReference: WorkflowRunTriggerReference | null;
|
|
15
|
+
/** The run's origin state, so checkout fallbacks can read the dev source. */
|
|
16
|
+
run: WorkflowRunOriginState;
|
|
15
17
|
}
|
|
16
18
|
export declare function getJobScope(jobId: string): Promise<JobScope | undefined>;
|
|
17
19
|
export declare function getDirectDependencyJobContexts(jobId: string, tx?: Tx): Promise<JobContextInput[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/jobs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEpG,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/jobs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAC,MAAM,uBAAuB,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,EAAE;IAC9D,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC,CAiDjE"}
|
|
@@ -10,7 +10,7 @@ import { writeWorkflowsOutboxEvent } from '../outbox-writes.js';
|
|
|
10
10
|
import { jobExecutions, toJobExecution } from '../schema/job-executions.js';
|
|
11
11
|
import { jobs, toJob } from '../schema/jobs.js';
|
|
12
12
|
import { workflowRunAttempts } from '../schema/workflow-run-attempts.js';
|
|
13
|
-
import { toWorkflowRun, workflowRuns } from '../schema/workflow-runs.js';
|
|
13
|
+
import { toWorkflowRun, toWorkflowRunOriginState, workflowRuns } from '../schema/workflow-runs.js';
|
|
14
14
|
import { getWorkflowRunById } from './queries.js';
|
|
15
15
|
import { getWorkflowContextForJob, optimisticLockRetry, TERMINAL_JOB_STATUSES } from './shared.js';
|
|
16
16
|
function outputTypesByJobKey(model) {
|
|
@@ -41,9 +41,18 @@ export async function getJobScope(jobId) {
|
|
|
41
41
|
const rows = await db().select({
|
|
42
42
|
workspaceId: workflowRuns.workspaceId,
|
|
43
43
|
projectId: workflowRuns.projectId,
|
|
44
|
-
triggerReference: workflowRuns.triggerReference
|
|
44
|
+
triggerReference: workflowRuns.triggerReference,
|
|
45
|
+
origin: workflowRuns.origin,
|
|
46
|
+
devSource: workflowRuns.devSource
|
|
45
47
|
}).from(jobs).innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id)).innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id)).where(eq(jobs.id, jobId)).limit(1);
|
|
46
|
-
|
|
48
|
+
const row = rows[0];
|
|
49
|
+
if (!row) return undefined;
|
|
50
|
+
return {
|
|
51
|
+
workspaceId: row.workspaceId,
|
|
52
|
+
projectId: row.projectId,
|
|
53
|
+
triggerReference: row.triggerReference,
|
|
54
|
+
run: toWorkflowRunOriginState(row)
|
|
55
|
+
};
|
|
47
56
|
}
|
|
48
57
|
export async function getDirectDependencyJobContexts(jobId, tx) {
|
|
49
58
|
const targetRows = await (tx ?? db()).select({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/workflow-runs/jobs.ts"],"sourcesContent":["import {readPersistedWorkflowModel} from '@shipfox/api-definitions-dto';\nimport {WORKFLOWS_JOB_TERMINATED} from '@shipfox/api-workflows-dto';\nimport type {ExpressionType} from '@shipfox/expression';\nimport {and, asc, desc, eq, inArray, notInArray, sql} from 'drizzle-orm';\nimport {isJobTerminal, type Job, type JobStatus, type JobStatusReason} from '#core/entities/job.js';\nimport type {JobExecution} from '#core/entities/job-execution.js';\nimport type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';\nimport type {WorkflowRunTriggerReference} from '#core/entities/workflow-run.js';\nimport {JobNotFoundError} from '#core/errors.js';\nimport {\n type DeriveJobSuccessResult,\n decideJobActivation,\n deriveJobSuccess,\n runtimeCompletionStatusForJob,\n} from '#core/job-transition/index.js';\nimport type {JobContextInput} from '#core/step-config/assemble-run-context.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport {recordWorkflowJobStatusChanged} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {jobExecutions, toJobExecution} from '../schema/job-executions.js';\nimport {jobs, toJob} from '../schema/jobs.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {getWorkflowRunById} from './queries.js';\nimport {getWorkflowContextForJob, optimisticLockRetry, TERMINAL_JOB_STATUSES} from './shared.js';\n\nfunction outputTypesByJobKey(\n model: ReturnType<typeof readPersistedWorkflowModel> | null,\n): ReadonlyMap<string, Readonly<Record<string, ExpressionType>>> {\n return new Map(\n (model?.jobs ?? []).flatMap((job) =>\n job.outputTypes === undefined ? [] : [[job.key, job.outputTypes] as const],\n ),\n );\n}\n\nexport async function getJobsByWorkflowRunAttemptId(workflowRunAttemptId: string): Promise<Job[]> {\n const rows = await db()\n .select()\n .from(jobs)\n .where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId))\n .orderBy(asc(jobs.position));\n return rows.map(toJob);\n}\n\nexport async function getJobsByWorkflowRunId(workflowRunId: string): Promise<Job[]> {\n const run = await getWorkflowRunById(workflowRunId);\n if (!run) return [];\n const [attempt] = await db()\n .select()\n .from(workflowRunAttempts)\n .where(\n and(\n eq(workflowRunAttempts.workflowRunId, run.id),\n eq(workflowRunAttempts.attempt, run.currentAttempt),\n ),\n )\n .limit(1);\n return attempt ? getJobsByWorkflowRunAttemptId(attempt.id) : [];\n}\n\nexport async function getJobById(id: string): Promise<Job | undefined> {\n const rows = await db().select().from(jobs).where(eq(jobs.id, id)).limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toJob(row);\n}\n\nexport interface JobScope {\n workspaceId: string;\n projectId: string;\n triggerReference: WorkflowRunTriggerReference | null;\n}\n\nexport async function getJobScope(jobId: string): Promise<JobScope | undefined> {\n const rows = await db()\n .select({\n workspaceId: workflowRuns.workspaceId,\n projectId: workflowRuns.projectId,\n triggerReference: workflowRuns.triggerReference,\n })\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(eq(jobs.id, jobId))\n .limit(1);\n return rows[0];\n}\n\nexport async function getDirectDependencyJobContexts(\n jobId: string,\n tx?: Tx,\n): Promise<JobContextInput[]> {\n const targetRows = await (tx ?? db())\n .select({job: jobs, attempt: workflowRunAttempts})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .where(eq(jobs.id, jobId))\n .limit(1);\n const target = targetRows[0];\n if (!target || target.job.dependencies.length === 0) return [];\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n const outputTypes = outputTypesByJobKey(model);\n\n const rows = await (tx ?? db())\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(\n and(\n eq(jobs.workflowRunAttemptId, target.job.workflowRunAttemptId),\n inArray(jobs.key, target.job.dependencies),\n ),\n )\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobId = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobId.get(row.job.id);\n if (!context) {\n const jobOutputTypes = outputTypes.get(row.job.key);\n context = {\n job: toJob(row.job),\n ...(jobOutputTypes === undefined ? {} : {outputTypes: jobOutputTypes}),\n executions: [],\n };\n contextsByJobId.set(row.job.id, context);\n }\n if (row.execution)\n context.executions.push(toJobExecution(row.execution, row.job.name ?? row.job.key));\n }\n\n return [...contextsByJobId.values()];\n}\n\nexport interface EvaluateJobActivationsParams {\n runAttemptId: string;\n jobs: readonly {\n jobId: string;\n expectedVersion: number;\n }[];\n}\n\nexport type JobActivationDecision =\n | {\n kind: 'start-job';\n jobId: string;\n }\n | {\n kind: 'terminal-job';\n jobId: string;\n status: RuntimeCompletionStatus;\n jobVersion: number;\n };\n\ntype InternalJobActivationDecision = JobActivationDecision & {changed?: boolean};\n\nexport async function evaluateJobActivations(\n params: EvaluateJobActivationsParams,\n): Promise<JobActivationDecision[]> {\n if (params.jobs.length === 0) return [];\n\n const result = await db().transaction(async (tx) => {\n const expectedVersions = new Map(\n params.jobs.map((job) => [job.jobId, job.expectedVersion] as const),\n );\n const jobIds = params.jobs.map((job) => job.jobId);\n const targets = await tx\n .select({job: jobs, attempt: workflowRunAttempts, run: workflowRuns})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(and(eq(jobs.workflowRunAttemptId, params.runAttemptId), inArray(jobs.id, jobIds)))\n .for('update');\n\n if (targets.length !== jobIds.length) {\n const found = new Set(targets.map((target) => target.job.id));\n const missing = jobIds.filter((jobId) => !found.has(jobId));\n throw new Error(`Cannot evaluate missing activation jobs: ${missing.join(', ')}`);\n }\n\n const contextsByJobKey = await directDependencyContextsByJobKey(\n tx,\n params.runAttemptId,\n targets.map((target) => toJob(target.job)),\n );\n const targetsByJobId = new Map(targets.map((target) => [target.job.id, target]));\n const decisions: InternalJobActivationDecision[] = [];\n\n for (const input of params.jobs) {\n const target = targetsByJobId.get(input.jobId);\n if (!target) throw new Error(`Cannot evaluate missing activation job: ${input.jobId}`);\n const job = toJob(target.job);\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n const modelJob = model?.jobs.find((item) => item.key === target.job.key);\n const decision = decideJobActivation({\n run: toWorkflowRun(target.run),\n job,\n condition: modelJob?.if,\n vars: target.attempt.vars ?? undefined,\n dependencies: job.dependencies.flatMap((key) => {\n const dependency = contextsByJobKey.get(key);\n return dependency === undefined ? [] : [dependency];\n }),\n });\n\n if (decision.kind === 'terminal-job' || decision.kind === 'start-job') {\n decisions.push(decision);\n continue;\n }\n\n const expectedVersion = expectedVersions.get(job.id);\n if (expectedVersion === undefined) {\n throw new Error(`Missing expected version for activation job ${job.id}`);\n }\n const updated = await updateJobStatusAtVersion(tx, {\n jobId: job.id,\n status: decision.status,\n expectedVersion,\n statusReason: decision.statusReason,\n evaluationTrace: decision.evaluationTrace,\n });\n if (updated) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: 'skipped',\n jobVersion: updated.job.version,\n changed: updated.changed,\n });\n continue;\n }\n\n const [existing] = await tx.select().from(jobs).where(eq(jobs.id, job.id)).limit(1);\n if (existing && isJobTerminal(existing.status)) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: runtimeCompletionStatusForJob(existing.status),\n jobVersion: existing.version,\n });\n continue;\n }\n throw new Error(`Optimistic lock failure evaluating activation for job ${job.id}`);\n }\n\n return decisions;\n });\n\n for (const decision of result) {\n if (decision.kind === 'terminal-job' && decision.changed) {\n recordWorkflowJobStatusChanged(decision.status);\n }\n }\n\n return result.map(({changed: _changed, ...decision}) => decision);\n}\n\nasync function directDependencyContextsByJobKey(\n tx: Tx,\n runAttemptId: string,\n targetJobs: readonly Job[],\n): Promise<ReadonlyMap<string, JobContextInput>> {\n const dependencyKeys = new Set(targetJobs.flatMap((job) => job.dependencies));\n if (dependencyKeys.size === 0) return new Map();\n\n const [attempt] = await tx\n .select({model: workflowRunAttempts.model})\n .from(workflowRunAttempts)\n .where(eq(workflowRunAttempts.id, runAttemptId))\n .limit(1);\n const model =\n attempt === undefined || attempt.model === null\n ? null\n : readPersistedWorkflowModel(attempt.model);\n const outputTypes = outputTypesByJobKey(model);\n\n const rows = await tx\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(and(eq(jobs.workflowRunAttemptId, runAttemptId), inArray(jobs.key, [...dependencyKeys])))\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobKey = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobKey.get(row.job.key);\n if (!context) {\n const jobOutputTypes = outputTypes.get(row.job.key);\n context = {\n job: toJob(row.job),\n ...(jobOutputTypes === undefined ? {} : {outputTypes: jobOutputTypes}),\n executions: [],\n };\n contextsByJobKey.set(row.job.key, context);\n }\n if (row.execution)\n context.executions.push(toJobExecution(row.execution, row.job.name ?? row.job.key));\n }\n\n return contextsByJobKey;\n}\n\nexport interface UpdateJobStatusAtVersionParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\n// Returns null on version mismatch so callers can choose throw vs treat-as-success.\nexport async function updateJobStatusAtVersion(\n tx: Tx,\n params: UpdateJobStatusAtVersionParams,\n): Promise<{job: Job; changed: boolean} | null> {\n const outputs = isJobTerminal(params.status)\n ? await reduceJobOutputs(tx, {jobId: params.jobId, status: params.status})\n : undefined;\n const rows = await tx\n .update(jobs)\n .set({\n status: params.status,\n statusReason: params.statusReason ?? null,\n ...(outputs === undefined ? {} : {outputs}),\n ...(params.evaluationTrace === undefined ? {} : {evaluationTrace: params.evaluationTrace}),\n version: sql`${jobs.version} + 1`,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(jobs.id, params.jobId),\n eq(jobs.version, params.expectedVersion),\n notInArray(jobs.status, TERMINAL_JOB_STATUSES),\n ),\n )\n .returning();\n\n const row = rows[0];\n if (!row) return null;\n const job = toJob(row);\n\n // Every terminal job-status write funnels through this one guarded UPDATE, where the\n // version match lets a single caller win. Emitting here, in the same transaction,\n // makes the terminal fact fire exactly once across all paths.\n if (isJobTerminal(job.status)) {\n const [currentExecution] = await tx\n .select({\n id: jobExecutions.id,\n statusReasonMessage: jobExecutions.statusReasonMessage,\n })\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, job.id))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n const identity = await getWorkflowContextForJob(job.id, tx);\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_TERMINATED,\n payload: {\n jobId: job.id,\n jobExecutionId: currentExecution?.id ?? null,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n status: job.status,\n statusReason: job.statusReason,\n statusReasonMessage: currentExecution?.statusReasonMessage ?? null,\n },\n });\n }\n\n return {job, changed: true};\n}\n\nasync function reduceJobOutputs(\n tx: Tx,\n params: {jobId: string; status: JobStatus},\n): Promise<Record<string, unknown> | null> {\n if (params.status !== 'succeeded') return null;\n\n const [row] = await tx\n .select({outputs: jobExecutions.outputs})\n .from(jobExecutions)\n .where(and(eq(jobExecutions.jobId, params.jobId), eq(jobExecutions.status, 'succeeded')))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n\n return row?.outputs ? {...row.outputs} : null;\n}\n\nexport interface UpdateJobStatusParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\nexport async function updateJobStatus(params: UpdateJobStatusParams): Promise<Job> {\n const statusReason = params.statusReason ?? null;\n const result = await db().transaction(async (tx) => {\n return await optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status: params.status,\n expectedVersion: params.expectedVersion,\n statusReason,\n evaluationTrace: params.evaluationTrace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n return row ? toJob(row) : undefined;\n },\n matchFn: (job) =>\n (job.status === params.status && job.statusReason === statusReason) ||\n isJobTerminal(job.status)\n ? {job, changed: false}\n : null,\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${params.expectedVersion}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n\n return result.job;\n}\n\nexport type EvaluateJobSuccessResult = DeriveJobSuccessResult;\nexport const evaluateJobSuccess = deriveJobSuccess;\n\nexport async function resolveJobStatusFromJobExecutions(params: {\n jobId: string;\n}): Promise<{status: RuntimeCompletionStatus; jobVersion: number}> {\n const result = await db().transaction(async (tx) => {\n const jobRow = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!jobRow) throw new JobNotFoundError(params.jobId);\n\n const jobExecutionRows = await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, params.jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n const workflowContext = await getWorkflowContextForJob(params.jobId, tx);\n\n if (jobExecutionRows.length === 0) {\n throw new Error(`Cannot resolve job ${params.jobId}: no job executions found`);\n }\n\n const {status, statusReason, trace} = evaluateJobSuccess({\n success: jobRow.success,\n executions: jobExecutionRows.map((execution) =>\n toJobExecution(execution, jobRow.name ?? jobRow.key),\n ),\n jobs: await getDirectDependencyJobContexts(params.jobId, tx),\n vars: workflowContext.vars ?? undefined,\n });\n\n return optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status,\n expectedVersion: jobRow.version,\n statusReason,\n evaluationTrace: trace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!row) throw new JobNotFoundError(params.jobId);\n return toJob(row);\n },\n matchFn: (job) => ({job, changed: false}),\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${jobRow.version}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n return {\n status: result.job.status === 'succeeded' ? 'succeeded' : 'failed',\n jobVersion: result.job.version,\n };\n}\n"],"names":["readPersistedWorkflowModel","WORKFLOWS_JOB_TERMINATED","and","asc","desc","eq","inArray","notInArray","sql","isJobTerminal","JobNotFoundError","decideJobActivation","deriveJobSuccess","runtimeCompletionStatusForJob","recordWorkflowJobStatusChanged","db","writeWorkflowsOutboxEvent","jobExecutions","toJobExecution","jobs","toJob","workflowRunAttempts","toWorkflowRun","workflowRuns","getWorkflowRunById","getWorkflowContextForJob","optimisticLockRetry","TERMINAL_JOB_STATUSES","outputTypesByJobKey","model","Map","flatMap","job","outputTypes","undefined","key","getJobsByWorkflowRunAttemptId","workflowRunAttemptId","rows","select","from","where","orderBy","position","map","getJobsByWorkflowRunId","workflowRunId","run","attempt","id","currentAttempt","limit","getJobById","row","getJobScope","jobId","workspaceId","projectId","triggerReference","innerJoin","getDirectDependencyJobContexts","tx","targetRows","target","dependencies","length","execution","leftJoin","sequence","contextsByJobId","context","get","jobOutputTypes","executions","set","push","name","values","evaluateJobActivations","params","result","transaction","expectedVersions","expectedVersion","jobIds","targets","runAttemptId","for","found","Set","missing","filter","has","Error","join","contextsByJobKey","directDependencyContextsByJobKey","targetsByJobId","decisions","input","modelJob","find","item","decision","condition","if","vars","dependency","kind","updated","updateJobStatusAtVersion","status","statusReason","evaluationTrace","jobVersion","version","changed","existing","_changed","targetJobs","dependencyKeys","size","outputs","reduceJobOutputs","update","updatedAt","Date","returning","currentExecution","statusReasonMessage","identity","type","payload","jobExecutionId","updateJobStatus","updateFn","fetchFn","matchFn","failureMessage","evaluateJobSuccess","resolveJobStatusFromJobExecutions","jobRow","jobExecutionRows","workflowContext","trace","success"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,+BAA+B;AACxE,SAAQC,wBAAwB,QAAO,6BAA6B;AAEpE,SAAQC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAEC,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEC,GAAG,QAAO,cAAc;AACzE,SAAQC,aAAa,QAAuD,wBAAwB;AAIpG,SAAQC,gBAAgB,QAAO,kBAAkB;AACjD,SAEEC,mBAAmB,EACnBC,gBAAgB,EAChBC,6BAA6B,QACxB,gCAAgC;AAGvC,SAAQC,8BAA8B,QAAO,uBAAuB;AACpE,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9D,SAAQC,aAAa,EAAEC,cAAc,QAAO,8BAA8B;AAC1E,SAAQC,IAAI,EAAEC,KAAK,QAAO,oBAAoB;AAC9C,SAAQC,mBAAmB,QAAO,qCAAqC;AACvE,SAAQC,aAAa,EAAEC,YAAY,QAAO,6BAA6B;AACvE,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAAQC,wBAAwB,EAAEC,mBAAmB,EAAEC,qBAAqB,QAAO,cAAc;AAEjG,SAASC,oBACPC,KAA2D;IAE3D,OAAO,IAAIC,IACT,AAACD,CAAAA,OAAOV,QAAQ,EAAE,AAAD,EAAGY,OAAO,CAA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db/workflow-runs/jobs.ts"],"sourcesContent":["import {readPersistedWorkflowModel} from '@shipfox/api-definitions-dto';\nimport {WORKFLOWS_JOB_TERMINATED} from '@shipfox/api-workflows-dto';\nimport type {ExpressionType} from '@shipfox/expression';\nimport {and, asc, desc, eq, inArray, notInArray, sql} from 'drizzle-orm';\nimport {isJobTerminal, type Job, type JobStatus, type JobStatusReason} from '#core/entities/job.js';\nimport type {JobExecution} from '#core/entities/job-execution.js';\nimport type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';\nimport type {\n WorkflowRunOriginState,\n WorkflowRunTriggerReference,\n} from '#core/entities/workflow-run.js';\nimport {JobNotFoundError} from '#core/errors.js';\nimport {\n type DeriveJobSuccessResult,\n decideJobActivation,\n deriveJobSuccess,\n runtimeCompletionStatusForJob,\n} from '#core/job-transition/index.js';\nimport type {JobContextInput} from '#core/step-config/assemble-run-context.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport {recordWorkflowJobStatusChanged} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {jobExecutions, toJobExecution} from '../schema/job-executions.js';\nimport {jobs, toJob} from '../schema/jobs.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, toWorkflowRunOriginState, workflowRuns} from '../schema/workflow-runs.js';\nimport {getWorkflowRunById} from './queries.js';\nimport {getWorkflowContextForJob, optimisticLockRetry, TERMINAL_JOB_STATUSES} from './shared.js';\n\nfunction outputTypesByJobKey(\n model: ReturnType<typeof readPersistedWorkflowModel> | null,\n): ReadonlyMap<string, Readonly<Record<string, ExpressionType>>> {\n return new Map(\n (model?.jobs ?? []).flatMap((job) =>\n job.outputTypes === undefined ? [] : [[job.key, job.outputTypes] as const],\n ),\n );\n}\n\nexport async function getJobsByWorkflowRunAttemptId(workflowRunAttemptId: string): Promise<Job[]> {\n const rows = await db()\n .select()\n .from(jobs)\n .where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId))\n .orderBy(asc(jobs.position));\n return rows.map(toJob);\n}\n\nexport async function getJobsByWorkflowRunId(workflowRunId: string): Promise<Job[]> {\n const run = await getWorkflowRunById(workflowRunId);\n if (!run) return [];\n const [attempt] = await db()\n .select()\n .from(workflowRunAttempts)\n .where(\n and(\n eq(workflowRunAttempts.workflowRunId, run.id),\n eq(workflowRunAttempts.attempt, run.currentAttempt),\n ),\n )\n .limit(1);\n return attempt ? getJobsByWorkflowRunAttemptId(attempt.id) : [];\n}\n\nexport async function getJobById(id: string): Promise<Job | undefined> {\n const rows = await db().select().from(jobs).where(eq(jobs.id, id)).limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toJob(row);\n}\n\nexport interface JobScope {\n workspaceId: string;\n projectId: string;\n triggerReference: WorkflowRunTriggerReference | null;\n /** The run's origin state, so checkout fallbacks can read the dev source. */\n run: WorkflowRunOriginState;\n}\n\nexport async function getJobScope(jobId: string): Promise<JobScope | undefined> {\n const rows = await db()\n .select({\n workspaceId: workflowRuns.workspaceId,\n projectId: workflowRuns.projectId,\n triggerReference: workflowRuns.triggerReference,\n origin: workflowRuns.origin,\n devSource: workflowRuns.devSource,\n })\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(eq(jobs.id, jobId))\n .limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return {\n workspaceId: row.workspaceId,\n projectId: row.projectId,\n triggerReference: row.triggerReference,\n run: toWorkflowRunOriginState(row),\n };\n}\n\nexport async function getDirectDependencyJobContexts(\n jobId: string,\n tx?: Tx,\n): Promise<JobContextInput[]> {\n const targetRows = await (tx ?? db())\n .select({job: jobs, attempt: workflowRunAttempts})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .where(eq(jobs.id, jobId))\n .limit(1);\n const target = targetRows[0];\n if (!target || target.job.dependencies.length === 0) return [];\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n const outputTypes = outputTypesByJobKey(model);\n\n const rows = await (tx ?? db())\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(\n and(\n eq(jobs.workflowRunAttemptId, target.job.workflowRunAttemptId),\n inArray(jobs.key, target.job.dependencies),\n ),\n )\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobId = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobId.get(row.job.id);\n if (!context) {\n const jobOutputTypes = outputTypes.get(row.job.key);\n context = {\n job: toJob(row.job),\n ...(jobOutputTypes === undefined ? {} : {outputTypes: jobOutputTypes}),\n executions: [],\n };\n contextsByJobId.set(row.job.id, context);\n }\n if (row.execution)\n context.executions.push(toJobExecution(row.execution, row.job.name ?? row.job.key));\n }\n\n return [...contextsByJobId.values()];\n}\n\nexport interface EvaluateJobActivationsParams {\n runAttemptId: string;\n jobs: readonly {\n jobId: string;\n expectedVersion: number;\n }[];\n}\n\nexport type JobActivationDecision =\n | {\n kind: 'start-job';\n jobId: string;\n }\n | {\n kind: 'terminal-job';\n jobId: string;\n status: RuntimeCompletionStatus;\n jobVersion: number;\n };\n\ntype InternalJobActivationDecision = JobActivationDecision & {changed?: boolean};\n\nexport async function evaluateJobActivations(\n params: EvaluateJobActivationsParams,\n): Promise<JobActivationDecision[]> {\n if (params.jobs.length === 0) return [];\n\n const result = await db().transaction(async (tx) => {\n const expectedVersions = new Map(\n params.jobs.map((job) => [job.jobId, job.expectedVersion] as const),\n );\n const jobIds = params.jobs.map((job) => job.jobId);\n const targets = await tx\n .select({job: jobs, attempt: workflowRunAttempts, run: workflowRuns})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(and(eq(jobs.workflowRunAttemptId, params.runAttemptId), inArray(jobs.id, jobIds)))\n .for('update');\n\n if (targets.length !== jobIds.length) {\n const found = new Set(targets.map((target) => target.job.id));\n const missing = jobIds.filter((jobId) => !found.has(jobId));\n throw new Error(`Cannot evaluate missing activation jobs: ${missing.join(', ')}`);\n }\n\n const contextsByJobKey = await directDependencyContextsByJobKey(\n tx,\n params.runAttemptId,\n targets.map((target) => toJob(target.job)),\n );\n const targetsByJobId = new Map(targets.map((target) => [target.job.id, target]));\n const decisions: InternalJobActivationDecision[] = [];\n\n for (const input of params.jobs) {\n const target = targetsByJobId.get(input.jobId);\n if (!target) throw new Error(`Cannot evaluate missing activation job: ${input.jobId}`);\n const job = toJob(target.job);\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n const modelJob = model?.jobs.find((item) => item.key === target.job.key);\n const decision = decideJobActivation({\n run: toWorkflowRun(target.run),\n job,\n condition: modelJob?.if,\n vars: target.attempt.vars ?? undefined,\n dependencies: job.dependencies.flatMap((key) => {\n const dependency = contextsByJobKey.get(key);\n return dependency === undefined ? [] : [dependency];\n }),\n });\n\n if (decision.kind === 'terminal-job' || decision.kind === 'start-job') {\n decisions.push(decision);\n continue;\n }\n\n const expectedVersion = expectedVersions.get(job.id);\n if (expectedVersion === undefined) {\n throw new Error(`Missing expected version for activation job ${job.id}`);\n }\n const updated = await updateJobStatusAtVersion(tx, {\n jobId: job.id,\n status: decision.status,\n expectedVersion,\n statusReason: decision.statusReason,\n evaluationTrace: decision.evaluationTrace,\n });\n if (updated) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: 'skipped',\n jobVersion: updated.job.version,\n changed: updated.changed,\n });\n continue;\n }\n\n const [existing] = await tx.select().from(jobs).where(eq(jobs.id, job.id)).limit(1);\n if (existing && isJobTerminal(existing.status)) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: runtimeCompletionStatusForJob(existing.status),\n jobVersion: existing.version,\n });\n continue;\n }\n throw new Error(`Optimistic lock failure evaluating activation for job ${job.id}`);\n }\n\n return decisions;\n });\n\n for (const decision of result) {\n if (decision.kind === 'terminal-job' && decision.changed) {\n recordWorkflowJobStatusChanged(decision.status);\n }\n }\n\n return result.map(({changed: _changed, ...decision}) => decision);\n}\n\nasync function directDependencyContextsByJobKey(\n tx: Tx,\n runAttemptId: string,\n targetJobs: readonly Job[],\n): Promise<ReadonlyMap<string, JobContextInput>> {\n const dependencyKeys = new Set(targetJobs.flatMap((job) => job.dependencies));\n if (dependencyKeys.size === 0) return new Map();\n\n const [attempt] = await tx\n .select({model: workflowRunAttempts.model})\n .from(workflowRunAttempts)\n .where(eq(workflowRunAttempts.id, runAttemptId))\n .limit(1);\n const model =\n attempt === undefined || attempt.model === null\n ? null\n : readPersistedWorkflowModel(attempt.model);\n const outputTypes = outputTypesByJobKey(model);\n\n const rows = await tx\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(and(eq(jobs.workflowRunAttemptId, runAttemptId), inArray(jobs.key, [...dependencyKeys])))\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobKey = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobKey.get(row.job.key);\n if (!context) {\n const jobOutputTypes = outputTypes.get(row.job.key);\n context = {\n job: toJob(row.job),\n ...(jobOutputTypes === undefined ? {} : {outputTypes: jobOutputTypes}),\n executions: [],\n };\n contextsByJobKey.set(row.job.key, context);\n }\n if (row.execution)\n context.executions.push(toJobExecution(row.execution, row.job.name ?? row.job.key));\n }\n\n return contextsByJobKey;\n}\n\nexport interface UpdateJobStatusAtVersionParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\n// Returns null on version mismatch so callers can choose throw vs treat-as-success.\nexport async function updateJobStatusAtVersion(\n tx: Tx,\n params: UpdateJobStatusAtVersionParams,\n): Promise<{job: Job; changed: boolean} | null> {\n const outputs = isJobTerminal(params.status)\n ? await reduceJobOutputs(tx, {jobId: params.jobId, status: params.status})\n : undefined;\n const rows = await tx\n .update(jobs)\n .set({\n status: params.status,\n statusReason: params.statusReason ?? null,\n ...(outputs === undefined ? {} : {outputs}),\n ...(params.evaluationTrace === undefined ? {} : {evaluationTrace: params.evaluationTrace}),\n version: sql`${jobs.version} + 1`,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(jobs.id, params.jobId),\n eq(jobs.version, params.expectedVersion),\n notInArray(jobs.status, TERMINAL_JOB_STATUSES),\n ),\n )\n .returning();\n\n const row = rows[0];\n if (!row) return null;\n const job = toJob(row);\n\n // Every terminal job-status write funnels through this one guarded UPDATE, where the\n // version match lets a single caller win. Emitting here, in the same transaction,\n // makes the terminal fact fire exactly once across all paths.\n if (isJobTerminal(job.status)) {\n const [currentExecution] = await tx\n .select({\n id: jobExecutions.id,\n statusReasonMessage: jobExecutions.statusReasonMessage,\n })\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, job.id))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n const identity = await getWorkflowContextForJob(job.id, tx);\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_TERMINATED,\n payload: {\n jobId: job.id,\n jobExecutionId: currentExecution?.id ?? null,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n status: job.status,\n statusReason: job.statusReason,\n statusReasonMessage: currentExecution?.statusReasonMessage ?? null,\n },\n });\n }\n\n return {job, changed: true};\n}\n\nasync function reduceJobOutputs(\n tx: Tx,\n params: {jobId: string; status: JobStatus},\n): Promise<Record<string, unknown> | null> {\n if (params.status !== 'succeeded') return null;\n\n const [row] = await tx\n .select({outputs: jobExecutions.outputs})\n .from(jobExecutions)\n .where(and(eq(jobExecutions.jobId, params.jobId), eq(jobExecutions.status, 'succeeded')))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n\n return row?.outputs ? {...row.outputs} : null;\n}\n\nexport interface UpdateJobStatusParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\nexport async function updateJobStatus(params: UpdateJobStatusParams): Promise<Job> {\n const statusReason = params.statusReason ?? null;\n const result = await db().transaction(async (tx) => {\n return await optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status: params.status,\n expectedVersion: params.expectedVersion,\n statusReason,\n evaluationTrace: params.evaluationTrace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n return row ? toJob(row) : undefined;\n },\n matchFn: (job) =>\n (job.status === params.status && job.statusReason === statusReason) ||\n isJobTerminal(job.status)\n ? {job, changed: false}\n : null,\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${params.expectedVersion}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n\n return result.job;\n}\n\nexport type EvaluateJobSuccessResult = DeriveJobSuccessResult;\nexport const evaluateJobSuccess = deriveJobSuccess;\n\nexport async function resolveJobStatusFromJobExecutions(params: {\n jobId: string;\n}): Promise<{status: RuntimeCompletionStatus; jobVersion: number}> {\n const result = await db().transaction(async (tx) => {\n const jobRow = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!jobRow) throw new JobNotFoundError(params.jobId);\n\n const jobExecutionRows = await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, params.jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n const workflowContext = await getWorkflowContextForJob(params.jobId, tx);\n\n if (jobExecutionRows.length === 0) {\n throw new Error(`Cannot resolve job ${params.jobId}: no job executions found`);\n }\n\n const {status, statusReason, trace} = evaluateJobSuccess({\n success: jobRow.success,\n executions: jobExecutionRows.map((execution) =>\n toJobExecution(execution, jobRow.name ?? jobRow.key),\n ),\n jobs: await getDirectDependencyJobContexts(params.jobId, tx),\n vars: workflowContext.vars ?? undefined,\n });\n\n return optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status,\n expectedVersion: jobRow.version,\n statusReason,\n evaluationTrace: trace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!row) throw new JobNotFoundError(params.jobId);\n return toJob(row);\n },\n matchFn: (job) => ({job, changed: false}),\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${jobRow.version}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n return {\n status: result.job.status === 'succeeded' ? 'succeeded' : 'failed',\n jobVersion: result.job.version,\n };\n}\n"],"names":["readPersistedWorkflowModel","WORKFLOWS_JOB_TERMINATED","and","asc","desc","eq","inArray","notInArray","sql","isJobTerminal","JobNotFoundError","decideJobActivation","deriveJobSuccess","runtimeCompletionStatusForJob","recordWorkflowJobStatusChanged","db","writeWorkflowsOutboxEvent","jobExecutions","toJobExecution","jobs","toJob","workflowRunAttempts","toWorkflowRun","toWorkflowRunOriginState","workflowRuns","getWorkflowRunById","getWorkflowContextForJob","optimisticLockRetry","TERMINAL_JOB_STATUSES","outputTypesByJobKey","model","Map","flatMap","job","outputTypes","undefined","key","getJobsByWorkflowRunAttemptId","workflowRunAttemptId","rows","select","from","where","orderBy","position","map","getJobsByWorkflowRunId","workflowRunId","run","attempt","id","currentAttempt","limit","getJobById","row","getJobScope","jobId","workspaceId","projectId","triggerReference","origin","devSource","innerJoin","getDirectDependencyJobContexts","tx","targetRows","target","dependencies","length","execution","leftJoin","sequence","contextsByJobId","context","get","jobOutputTypes","executions","set","push","name","values","evaluateJobActivations","params","result","transaction","expectedVersions","expectedVersion","jobIds","targets","runAttemptId","for","found","Set","missing","filter","has","Error","join","contextsByJobKey","directDependencyContextsByJobKey","targetsByJobId","decisions","input","modelJob","find","item","decision","condition","if","vars","dependency","kind","updated","updateJobStatusAtVersion","status","statusReason","evaluationTrace","jobVersion","version","changed","existing","_changed","targetJobs","dependencyKeys","size","outputs","reduceJobOutputs","update","updatedAt","Date","returning","currentExecution","statusReasonMessage","identity","type","payload","jobExecutionId","updateJobStatus","updateFn","fetchFn","matchFn","failureMessage","evaluateJobSuccess","resolveJobStatusFromJobExecutions","jobRow","jobExecutionRows","workflowContext","trace","success"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,+BAA+B;AACxE,SAAQC,wBAAwB,QAAO,6BAA6B;AAEpE,SAAQC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAEC,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEC,GAAG,QAAO,cAAc;AACzE,SAAQC,aAAa,QAAuD,wBAAwB;AAOpG,SAAQC,gBAAgB,QAAO,kBAAkB;AACjD,SAEEC,mBAAmB,EACnBC,gBAAgB,EAChBC,6BAA6B,QACxB,gCAAgC;AAGvC,SAAQC,8BAA8B,QAAO,uBAAuB;AACpE,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9D,SAAQC,aAAa,EAAEC,cAAc,QAAO,8BAA8B;AAC1E,SAAQC,IAAI,EAAEC,KAAK,QAAO,oBAAoB;AAC9C,SAAQC,mBAAmB,QAAO,qCAAqC;AACvE,SAAQC,aAAa,EAAEC,wBAAwB,EAAEC,YAAY,QAAO,6BAA6B;AACjG,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAAQC,wBAAwB,EAAEC,mBAAmB,EAAEC,qBAAqB,QAA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gBAAK,CAAA;YACvCsB,gBAAgB,CAAC,6BAA6B,EAAE3D,OAAO1B,KAAK,CAAC,SAAS,EAAEwF,OAAO1B,OAAO,EAAE;QAC1F;IACF;IAEA,IAAInC,OAAOoC,OAAO,EAAEzG,+BAA+BqE,OAAOlD,GAAG,CAACiF,MAAM;IACpE,OAAO;QACLA,QAAQ/B,OAAOlD,GAAG,CAACiF,MAAM,KAAK,cAAc,cAAc;QAC1DG,YAAYlC,OAAOlD,GAAG,CAACqF,OAAO;IAChC;AACF"}
|
|
@@ -2,12 +2,13 @@ import { type TimestampIdCursor } from '@shipfox/node-drizzle';
|
|
|
2
2
|
import { type SQL } from 'drizzle-orm';
|
|
3
3
|
import type { JobMode, JobStatus, ListenerStatus } from '#core/entities/job.js';
|
|
4
4
|
import type { JobExecutionStatus } from '#core/entities/job-execution.js';
|
|
5
|
-
import type { JobExecutionDetail, WorkflowRun, WorkflowRunDetail, WorkflowRunStatus } from '#core/entities/workflow-run.js';
|
|
5
|
+
import type { JobExecutionDetail, WorkflowRun, WorkflowRunDetail, WorkflowRunOrigin, WorkflowRunStatus } from '#core/entities/workflow-run.js';
|
|
6
6
|
export type WorkflowRunCursor = TimestampIdCursor;
|
|
7
7
|
export interface WorkflowRunFilters {
|
|
8
8
|
status?: WorkflowRunStatus | undefined;
|
|
9
9
|
definitionId?: string | undefined;
|
|
10
10
|
triggerSource?: string | undefined;
|
|
11
|
+
origin?: WorkflowRunOrigin | undefined;
|
|
11
12
|
createdFrom?: Date | undefined;
|
|
12
13
|
createdTo?: Date | undefined;
|
|
13
14
|
}
|
|
@@ -70,7 +71,7 @@ export declare function buildWorkflowRunListConditions(params: {
|
|
|
70
71
|
projectId: string;
|
|
71
72
|
filters?: WorkflowRunFilters | undefined;
|
|
72
73
|
cursor?: WorkflowRunCursor | undefined;
|
|
73
|
-
omit?: 'status' | 'definitionId' | 'triggerSource' | undefined;
|
|
74
|
+
omit?: 'status' | 'definitionId' | 'triggerSource' | 'origin' | undefined;
|
|
74
75
|
}): SQL[];
|
|
75
76
|
export declare function listWorkflowRuns(params: ListWorkflowRunsParams): Promise<ListWorkflowRunsResult>;
|
|
76
77
|
/** The run whose jobs to fetch, pinned to the attempt the caller already read. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAsC,KAAK,GAAG,EAAM,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EACV,kBAAkB,EAGlB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AASxC,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvC,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,WAAW,EAAE,CAAC;I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,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,SAAS,2BAA2B,EAAE,GAC3C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAqI9C;AA+BD,wBAAsB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAGzF;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC1C,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAgDjC;AAED,wBAAsB,4BAA4B,CAChD,MAAM,GAAE,+BAAoC,GAC3C,OAAO,CAAC,yBAAyB,CAAC,CA0BpC;AAED,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA+CxC;AAED,wBAAsB,qBAAqB,CACzC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAwCzC"}
|
|
@@ -57,6 +57,9 @@ export function buildWorkflowRunListConditions(params) {
|
|
|
57
57
|
if (filters?.triggerSource && params.omit !== 'triggerSource') {
|
|
58
58
|
conditions.push(eq(workflowRuns.triggerSource, filters.triggerSource));
|
|
59
59
|
}
|
|
60
|
+
if (filters?.origin && params.omit !== 'origin') {
|
|
61
|
+
conditions.push(eq(workflowRuns.origin, filters.origin));
|
|
62
|
+
}
|
|
60
63
|
if (filters?.createdFrom) {
|
|
61
64
|
conditions.push(gte(workflowRuns.createdAt, filters.createdFrom));
|
|
62
65
|
}
|