@shipfox/api-workflows 8.0.0 → 9.0.1
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 +65 -0
- package/dist/core/agent-tools.d.ts +3 -1
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/errors.d.ts +0 -4
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +0 -6
- package/dist/core/errors.js.map +1 -1
- package/dist/core/job-execution.d.ts +0 -2
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +3 -7
- package/dist/core/job-execution.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +0 -5
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +0 -7
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +1 -1
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +1 -1
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/presentation/routes/next-step.d.ts.map +1 -1
- package/dist/presentation/routes/next-step.js +11 -8
- package/dist/presentation/routes/next-step.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +26 -28
- package/src/core/agent-tool-capability-warning.test.ts +25 -55
- package/src/core/agent-tools.ts +7 -5
- package/src/core/errors.ts +0 -7
- package/src/core/job-execution.ts +3 -10
- package/src/core/run-workflow.test.ts +20 -55
- package/src/core/step-config/materialize-job-execution-steps.test.ts +1 -2
- package/src/core/step-config/materialize-workflow-model.test.ts +11 -23
- package/src/db/workflow-runs/job-executions.ts +0 -21
- package/src/db/workflow-runs/run-create.test.ts +31 -33
- package/src/db/workflow-runs.ts +0 -1
- package/src/index.ts +1 -1
- package/src/presentation/dto/checkout-token.test.ts +7 -1
- package/src/presentation/routes/agent-runtime-config.test.ts +38 -97
- package/src/presentation/routes/next-step.test.ts +18 -12
- package/src/presentation/routes/next-step.ts +9 -5
- package/test/factories/workflow-model.ts +3 -1
- package/test/fixtures/active-lease-token.ts +5 -32
- package/test/fixtures/agent-inter-module.ts +3 -2
- package/test/fixtures/runners-inter-module.ts +40 -48
- package/test/globalSetup.ts +0 -38
- package/test/setup.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/db/runner-lease-table.d.ts +0 -469
- package/dist/db/runner-lease-table.d.ts.map +0 -1
- package/dist/db/runner-lease-table.js +0 -43
- package/dist/db/runner-lease-table.js.map +0 -1
- package/src/db/runner-lease-table.ts +0 -39
|
@@ -7,7 +7,6 @@ import { deriveCompletion, isTerminal } from '#core/step-transition/decide-step-
|
|
|
7
7
|
import { recordWorkflowJobExecutionLeaseExpiryResolved, recordWorkflowJobExecutionQueued, recordWorkflowJobExecutionStarted, recordWorkflowJobExecutionStatusChanged, recordWorkflowJobExecutionTimedOut } from '#metrics/instance.js';
|
|
8
8
|
import { db } from '../db.js';
|
|
9
9
|
import { writeWorkflowsOutboxEvent } from '../outbox-writes.js';
|
|
10
|
-
import { runningJobExecutions } from '../runner-lease-table.js';
|
|
11
10
|
import { jobExecutions, toJobExecution } from '../schema/job-executions.js';
|
|
12
11
|
import { jobs, toJob } from '../schema/jobs.js';
|
|
13
12
|
import { stepAttempts, toStepAttempt } from '../schema/step-attempts.js';
|
|
@@ -18,12 +17,6 @@ import { getDirectDependencyJobContexts } from './jobs.js';
|
|
|
18
17
|
import { loadReferencedVariables } from './runs.js';
|
|
19
18
|
import { getWorkflowContextForJob, optimisticLockRetry, TERMINAL_EXECUTION_STATUSES } from './shared.js';
|
|
20
19
|
import { bulkUpdateStepStatuses, getStepsByJobExecutionIdForUpdate } from './steps.js';
|
|
21
|
-
export async function lockActiveJobExecutionLeaseForUpdate(params, tx) {
|
|
22
|
-
const rows = await tx.select({
|
|
23
|
-
id: runningJobExecutions.id
|
|
24
|
-
}).from(runningJobExecutions).where(and(eq(runningJobExecutions.jobId, params.jobId), eq(runningJobExecutions.jobExecutionId, params.jobExecutionId), eq(runningJobExecutions.runnerSessionId, params.runnerSessionId))).limit(1).for('update');
|
|
25
|
-
return rows.length > 0;
|
|
26
|
-
}
|
|
27
20
|
export async function getJobExecutionById(id, tx) {
|
|
28
21
|
const rows = await (tx ?? db()).select().from(jobExecutions).where(eq(jobExecutions.id, id)).limit(1);
|
|
29
22
|
const row = rows[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/workflow-runs/job-executions.ts"],"sourcesContent":["import {readPersistedWorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {WORKFLOWS_JOB_EXECUTION_TIMED_OUT} from '@shipfox/api-workflows-dto';\nimport {and, asc, desc, eq, isNull, notInArray, sql} from 'drizzle-orm';\nimport type {JobStatusReason} from '#core/entities/job.js';\nimport type {JobExecution, JobExecutionStatus} from '#core/entities/job-execution.js';\nimport {InterpolationUnresolvableError, JobNotFoundError} from '#core/errors.js';\nimport {deriveJobExecutionOutputs} from '#core/job-transition/index.js';\nimport {deriveCompletion, isTerminal} from '#core/step-transition/decide-step-transition.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport {\n recordWorkflowJobExecutionLeaseExpiryResolved,\n recordWorkflowJobExecutionQueued,\n recordWorkflowJobExecutionStarted,\n recordWorkflowJobExecutionStatusChanged,\n recordWorkflowJobExecutionTimedOut,\n} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {runningJobExecutions} from '../runner-lease-table.js';\nimport {jobExecutions, toJobExecution} from '../schema/job-executions.js';\nimport {jobs, toJob} from '../schema/jobs.js';\nimport {stepAttempts, toStepAttempt} from '../schema/step-attempts.js';\nimport {steps, toStep} from '../schema/steps.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {getDirectDependencyJobContexts} from './jobs.js';\nimport {loadReferencedVariables} from './runs.js';\nimport {\n getWorkflowContextForJob,\n optimisticLockRetry,\n TERMINAL_EXECUTION_STATUSES,\n} from './shared.js';\nimport {bulkUpdateStepStatuses, getStepsByJobExecutionIdForUpdate} from './steps.js';\n\nexport async function lockActiveJobExecutionLeaseForUpdate(\n params: {jobId: string; jobExecutionId: string; runnerSessionId: string},\n tx: Tx,\n): Promise<boolean> {\n const rows = await tx\n .select({id: runningJobExecutions.id})\n .from(runningJobExecutions)\n .where(\n and(\n eq(runningJobExecutions.jobId, params.jobId),\n eq(runningJobExecutions.jobExecutionId, params.jobExecutionId),\n eq(runningJobExecutions.runnerSessionId, params.runnerSessionId),\n ),\n )\n .limit(1)\n .for('update');\n\n return rows.length > 0;\n}\n\nexport async function getJobExecutionById(id: string, tx?: Tx): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport async function getJobExecutionsByWorkflowRunAttemptId(\n workflowRunAttemptId: string,\n): Promise<JobExecution[]> {\n const rows = await db()\n .select({jobExecution: jobExecutions})\n .from(jobExecutions)\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n return rows.map((row) => toJobExecution(row.jobExecution));\n}\n\nexport async function getJobExecutionsByJobId(jobId: string): Promise<JobExecution[]> {\n const rows = await db()\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n return rows.map(toJobExecution);\n}\n\nexport async function getFirstJobExecutionByJobId(\n jobId: string,\n tx?: Tx,\n): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport async function getLatestJobExecutionByJobId(\n jobId: string,\n tx?: Tx,\n): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport interface UpdateJobExecutionStatusAtVersionParams {\n jobExecutionId: string;\n status: JobExecutionStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n markTimedOut?: boolean;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}\n\nasync function resolveJobExecutionOutputs(\n tx: Tx,\n params: {\n jobExecutionId: string;\n status: JobExecutionStatus;\n statusReason: JobStatusReason | null;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n },\n): Promise<Record<string, unknown> | null> {\n const [target] = await tx\n .select({execution: jobExecutions, job: jobs, attempt: workflowRunAttempts, run: workflowRuns})\n .from(jobExecutions)\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1);\n if (!target) throw new JobNotFoundError(params.jobExecutionId);\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n if (!model) return null;\n const modelJob = model.jobs.find((job) => job.key === target.job.key);\n if (!modelJob || modelJob.outputs === undefined) return null;\n\n const executionRows = await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, target.job.id))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n const executions = executionRows.map((row) =>\n row.id === target.execution.id\n ? toJobExecution({...row, status: params.status, statusReason: params.statusReason})\n : toJobExecution(row),\n );\n const jobExecution = executions.find((execution) => execution.id === target.execution.id);\n if (!jobExecution) throw new JobNotFoundError(params.jobExecutionId);\n\n const stepRows = await tx\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, params.jobExecutionId))\n .orderBy(asc(steps.position), asc(steps.id));\n const attemptRows = await tx\n .select()\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, params.jobExecutionId))\n .orderBy(asc(stepAttempts.executionOrder), asc(stepAttempts.id));\n const dependencyJobs = await getDirectDependencyJobContexts(target.job.id, tx);\n\n return deriveJobExecutionOutputs({\n run: toWorkflowRun(target.run),\n modelJob,\n job: toJob(target.job),\n jobExecution,\n executions,\n steps: stepRows.map(toStep),\n attempts: attemptRows.map(toStepAttempt),\n jobs: dependencyJobs,\n vars: await loadReferencedVariables({\n model,\n jobs: [modelJob],\n workspaceId: target.run.workspaceId,\n projectId: target.run.projectId,\n definitionId: target.run.definitionId,\n secrets: params.secrets,\n }),\n });\n}\n\nasync function updateJobExecutionStatusAtVersion(\n tx: Tx,\n params: UpdateJobExecutionStatusAtVersionParams,\n): Promise<{execution: JobExecution; changed: boolean} | null> {\n let status = params.status;\n let statusReason = params.statusReason ?? null;\n let outputs: Record<string, unknown> | null | undefined;\n if (TERMINAL_EXECUTION_STATUSES.includes(status)) {\n outputs = null;\n }\n if (status === 'succeeded') {\n try {\n outputs = await resolveJobExecutionOutputs(tx, {\n jobExecutionId: params.jobExecutionId,\n status,\n statusReason,\n secrets: params.secrets,\n });\n } catch (error) {\n if (!(error instanceof InterpolationUnresolvableError)) throw error;\n status = 'failed';\n statusReason = 'unknown';\n outputs = null;\n }\n }\n\n const rows = await tx\n .update(jobExecutions)\n .set({\n status,\n statusReason,\n ...(outputs === undefined ? {} : {outputs}),\n version: sql`${jobExecutions.version} + 1`,\n updatedAt: new Date(),\n ...(params.markTimedOut ? {timedOutAt: new Date()} : {}),\n ...(TERMINAL_EXECUTION_STATUSES.includes(status) ? {finishedAt: sql`now()`} : {}),\n })\n .where(\n and(\n eq(jobExecutions.id, params.jobExecutionId),\n eq(jobExecutions.version, params.expectedVersion),\n notInArray(jobExecutions.status, TERMINAL_EXECUTION_STATUSES),\n ),\n )\n .returning();\n\n const row = rows[0];\n if (!row) return null;\n return {execution: toJobExecution(row), changed: true};\n}\n\nexport interface UpdateJobExecutionStatusParams {\n jobExecutionId: string;\n status: JobExecutionStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}\n\nexport async function updateJobExecutionStatus(\n params: UpdateJobExecutionStatusParams,\n): Promise<JobExecution> {\n const statusReason = params.statusReason ?? null;\n const result = await db().transaction(async (tx) => {\n return await optimisticLockRetry({\n updateFn: () =>\n updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: params.status,\n expectedVersion: params.expectedVersion,\n statusReason,\n secrets: params.secrets,\n }),\n fetchFn: async () => {\n const row = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n return row ? toJobExecution(row) : undefined;\n },\n matchFn: (execution) =>\n (execution.status === params.status && execution.statusReason === statusReason) ||\n TERMINAL_EXECUTION_STATUSES.includes(execution.status)\n ? {execution, changed: false}\n : null,\n failureMessage: `Optimistic lock failure: job execution ${params.jobExecutionId} version ${params.expectedVersion}`,\n });\n });\n\n if (result.changed) recordWorkflowJobExecutionStatusChanged(result.execution.status);\n\n return result.execution;\n}\n\nexport async function recordJobExecutionQueuedAt(params: {\n jobExecutionId: string;\n queuedAt: Date;\n}): Promise<void> {\n const updated = await db()\n .update(jobExecutions)\n .set({queuedAt: params.queuedAt})\n .where(and(eq(jobExecutions.id, params.jobExecutionId), isNull(jobExecutions.queuedAt)))\n .returning({id: jobExecutions.id});\n\n if (updated.length > 0) recordWorkflowJobExecutionQueued();\n}\n\nexport async function recordJobExecutionStartedAt(params: {\n jobExecutionId: string;\n startedAt: Date;\n}): Promise<void> {\n const updated = await db()\n .update(jobExecutions)\n .set({startedAt: params.startedAt})\n .where(and(eq(jobExecutions.id, params.jobExecutionId), isNull(jobExecutions.startedAt)))\n .returning({id: jobExecutions.id});\n\n if (updated.length > 0) recordWorkflowJobExecutionStarted();\n}\n\nexport async function failJobExecutionAsTimedOut(params: {\n jobExecutionId: string;\n workflowRunAttemptId: string;\n expectedVersion: number;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}): Promise<JobExecution> {\n const result = await db().transaction(async (tx) => {\n const updated = await optimisticLockRetry({\n updateFn: () =>\n updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: 'failed',\n expectedVersion: params.expectedVersion,\n statusReason: 'timed_out',\n markTimedOut: true,\n secrets: params.secrets,\n }),\n fetchFn: async () => {\n const row = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n return row ? toJobExecution(row) : undefined;\n },\n matchFn: (execution) => (execution.timedOutAt !== null ? {execution, changed: false} : null),\n failureMessage: `Optimistic lock failure: job execution ${params.jobExecutionId} version ${params.expectedVersion}`,\n });\n\n if (updated.changed) {\n const identity = await getWorkflowContextForJob(updated.execution.jobId, tx);\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_EXECUTION_TIMED_OUT,\n payload: {\n jobId: identity.jobId,\n jobExecutionId: params.jobExecutionId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n },\n });\n }\n\n return updated;\n });\n\n if (result.changed) {\n recordWorkflowJobExecutionStatusChanged(result.execution.status);\n recordWorkflowJobExecutionTimedOut();\n }\n\n return result.execution;\n}\n\nexport async function resolveJobExecutionAfterLeaseExpiry(params: {\n jobExecutionId: string;\n expectedVersion: number;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}): Promise<{status: RuntimeCompletionStatus; executionVersion: number}> {\n const result = await db().transaction(async (tx) => {\n const jobExecutionSteps = await getStepsByJobExecutionIdForUpdate(params.jobExecutionId, tx);\n let changedJobExecution: JobExecution | null = null;\n\n if (jobExecutionSteps.length === 0) {\n throw new JobNotFoundError(params.jobExecutionId);\n }\n\n if (jobExecutionSteps.every((step) => isTerminal(step.status))) {\n const status = deriveCompletion(jobExecutionSteps);\n const updated = await updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status,\n expectedVersion: params.expectedVersion,\n statusReason: statusReasonForStepCompletion(status),\n secrets: params.secrets,\n });\n changedJobExecution = updated?.changed ? updated.execution : null;\n } else {\n const updated = await updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: 'failed',\n expectedVersion: params.expectedVersion,\n statusReason: 'runner_lost',\n secrets: params.secrets,\n });\n if (updated?.changed) {\n changedJobExecution = updated.execution;\n await bulkUpdateStepStatuses(\n {jobExecutionId: params.jobExecutionId, status: 'cancelled'},\n tx,\n );\n }\n }\n\n const jobExecutionRow = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n if (!jobExecutionRow) {\n throw new Error(`Job execution not found resolving lease expiry: ${params.jobExecutionId}`);\n }\n const status: RuntimeCompletionStatus =\n jobExecutionRow.status === 'succeeded' ? 'succeeded' : 'failed';\n return {status, executionVersion: jobExecutionRow.version, changedJobExecution};\n });\n\n recordWorkflowJobExecutionLeaseExpiryResolved(result.status);\n if (result.changedJobExecution) {\n recordWorkflowJobExecutionStatusChanged(result.changedJobExecution.status);\n }\n\n return {status: result.status, executionVersion: result.executionVersion};\n}\n\nfunction statusReasonForStepCompletion(status: RuntimeCompletionStatus): JobStatusReason | null {\n return status === 'failed' ? 'step_failed' : null;\n}\n"],"names":["readPersistedWorkflowModel","WORKFLOWS_JOB_EXECUTION_TIMED_OUT","and","asc","desc","eq","isNull","notInArray","sql","InterpolationUnresolvableError","JobNotFoundError","deriveJobExecutionOutputs","deriveCompletion","isTerminal","recordWorkflowJobExecutionLeaseExpiryResolved","recordWorkflowJobExecutionQueued","recordWorkflowJobExecutionStarted","recordWorkflowJobExecutionStatusChanged","recordWorkflowJobExecutionTimedOut","db","writeWorkflowsOutboxEvent","runningJobExecutions","jobExecutions","toJobExecution","jobs","toJob","stepAttempts","toStepAttempt","steps","toStep","workflowRunAttempts","toWorkflowRun","workflowRuns","getDirectDependencyJobContexts","loadReferencedVariables","getWorkflowContextForJob","optimisticLockRetry","TERMINAL_EXECUTION_STATUSES","bulkUpdateStepStatuses","getStepsByJobExecutionIdForUpdate","lockActiveJobExecutionLeaseForUpdate","params","tx","rows","select","id","from","where","jobId","jobExecutionId","runnerSessionId","limit","for","length","getJobExecutionById","row","undefined","getJobExecutionsByWorkflowRunAttemptId","workflowRunAttemptId","jobExecution","innerJoin","orderBy","sequence","map","getJobExecutionsByJobId","getFirstJobExecutionByJobId","getLatestJobExecutionByJobId","resolveJobExecutionOutputs","target","execution","job","attempt","run","workflowRunId","model","modelJob","find","key","outputs","executionRows","executions","status","statusReason","stepRows","position","attemptRows","executionOrder","dependencyJobs","attempts","vars","workspaceId","projectId","definitionId","secrets","updateJobExecutionStatusAtVersion","includes","error","update","set","version","updatedAt","Date","markTimedOut","timedOutAt","finishedAt","expectedVersion","returning","changed","updateJobExecutionStatus","result","transaction","updateFn","fetchFn","matchFn","failureMessage","recordJobExecutionQueuedAt","updated","queuedAt","recordJobExecutionStartedAt","startedAt","failJobExecutionAsTimedOut","identity","type","payload","resolveJobExecutionAfterLeaseExpiry","jobExecutionSteps","changedJobExecution","every","step","statusReasonForStepCompletion","jobExecutionRow","Error","executionVersion"],"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AAOiB,mBAAmB,EAAE;QAC9B7G,wCAAwC4F,OAAOiB,mBAAmB,CAAC7C,MAAM;IAC3E;IAEA,OAAO;QAACA,QAAQ4B,OAAO5B,MAAM;QAAEmD,kBAAkBvB,OAAOuB,gBAAgB;IAAA;AAC1E;AAEA,SAASH,8BAA8BhD,MAA+B;IACpE,OAAOA,WAAW,WAAW,gBAAgB;AAC/C"}
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/job-executions.ts"],"sourcesContent":["import {readPersistedWorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {WORKFLOWS_JOB_EXECUTION_TIMED_OUT} from '@shipfox/api-workflows-dto';\nimport {and, asc, desc, eq, isNull, notInArray, sql} from 'drizzle-orm';\nimport type {JobStatusReason} from '#core/entities/job.js';\nimport type {JobExecution, JobExecutionStatus} from '#core/entities/job-execution.js';\nimport {InterpolationUnresolvableError, JobNotFoundError} from '#core/errors.js';\nimport {deriveJobExecutionOutputs} from '#core/job-transition/index.js';\nimport {deriveCompletion, isTerminal} from '#core/step-transition/decide-step-transition.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport {\n recordWorkflowJobExecutionLeaseExpiryResolved,\n recordWorkflowJobExecutionQueued,\n recordWorkflowJobExecutionStarted,\n recordWorkflowJobExecutionStatusChanged,\n recordWorkflowJobExecutionTimedOut,\n} 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 {stepAttempts, toStepAttempt} from '../schema/step-attempts.js';\nimport {steps, toStep} from '../schema/steps.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {getDirectDependencyJobContexts} from './jobs.js';\nimport {loadReferencedVariables} from './runs.js';\nimport {\n getWorkflowContextForJob,\n optimisticLockRetry,\n TERMINAL_EXECUTION_STATUSES,\n} from './shared.js';\nimport {bulkUpdateStepStatuses, getStepsByJobExecutionIdForUpdate} from './steps.js';\n\nexport async function getJobExecutionById(id: string, tx?: Tx): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport async function getJobExecutionsByWorkflowRunAttemptId(\n workflowRunAttemptId: string,\n): Promise<JobExecution[]> {\n const rows = await db()\n .select({jobExecution: jobExecutions})\n .from(jobExecutions)\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n return rows.map((row) => toJobExecution(row.jobExecution));\n}\n\nexport async function getJobExecutionsByJobId(jobId: string): Promise<JobExecution[]> {\n const rows = await db()\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n return rows.map(toJobExecution);\n}\n\nexport async function getFirstJobExecutionByJobId(\n jobId: string,\n tx?: Tx,\n): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport async function getLatestJobExecutionByJobId(\n jobId: string,\n tx?: Tx,\n): Promise<JobExecution | undefined> {\n const rows = await (tx ?? db())\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, jobId))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n const row = rows[0];\n return row ? toJobExecution(row) : undefined;\n}\n\nexport interface UpdateJobExecutionStatusAtVersionParams {\n jobExecutionId: string;\n status: JobExecutionStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n markTimedOut?: boolean;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}\n\nasync function resolveJobExecutionOutputs(\n tx: Tx,\n params: {\n jobExecutionId: string;\n status: JobExecutionStatus;\n statusReason: JobStatusReason | null;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n },\n): Promise<Record<string, unknown> | null> {\n const [target] = await tx\n .select({execution: jobExecutions, job: jobs, attempt: workflowRunAttempts, run: workflowRuns})\n .from(jobExecutions)\n .innerJoin(jobs, eq(jobExecutions.jobId, jobs.id))\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1);\n if (!target) throw new JobNotFoundError(params.jobExecutionId);\n const model =\n target.attempt.model === null ? null : readPersistedWorkflowModel(target.attempt.model);\n if (!model) return null;\n const modelJob = model.jobs.find((job) => job.key === target.job.key);\n if (!modelJob || modelJob.outputs === undefined) return null;\n\n const executionRows = await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, target.job.id))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n const executions = executionRows.map((row) =>\n row.id === target.execution.id\n ? toJobExecution({...row, status: params.status, statusReason: params.statusReason})\n : toJobExecution(row),\n );\n const jobExecution = executions.find((execution) => execution.id === target.execution.id);\n if (!jobExecution) throw new JobNotFoundError(params.jobExecutionId);\n\n const stepRows = await tx\n .select()\n .from(steps)\n .where(eq(steps.jobExecutionId, params.jobExecutionId))\n .orderBy(asc(steps.position), asc(steps.id));\n const attemptRows = await tx\n .select()\n .from(stepAttempts)\n .where(eq(stepAttempts.jobExecutionId, params.jobExecutionId))\n .orderBy(asc(stepAttempts.executionOrder), asc(stepAttempts.id));\n const dependencyJobs = await getDirectDependencyJobContexts(target.job.id, tx);\n\n return deriveJobExecutionOutputs({\n run: toWorkflowRun(target.run),\n modelJob,\n job: toJob(target.job),\n jobExecution,\n executions,\n steps: stepRows.map(toStep),\n attempts: attemptRows.map(toStepAttempt),\n jobs: dependencyJobs,\n vars: await loadReferencedVariables({\n model,\n jobs: [modelJob],\n workspaceId: target.run.workspaceId,\n projectId: target.run.projectId,\n definitionId: target.run.definitionId,\n secrets: params.secrets,\n }),\n });\n}\n\nasync function updateJobExecutionStatusAtVersion(\n tx: Tx,\n params: UpdateJobExecutionStatusAtVersionParams,\n): Promise<{execution: JobExecution; changed: boolean} | null> {\n let status = params.status;\n let statusReason = params.statusReason ?? null;\n let outputs: Record<string, unknown> | null | undefined;\n if (TERMINAL_EXECUTION_STATUSES.includes(status)) {\n outputs = null;\n }\n if (status === 'succeeded') {\n try {\n outputs = await resolveJobExecutionOutputs(tx, {\n jobExecutionId: params.jobExecutionId,\n status,\n statusReason,\n secrets: params.secrets,\n });\n } catch (error) {\n if (!(error instanceof InterpolationUnresolvableError)) throw error;\n status = 'failed';\n statusReason = 'unknown';\n outputs = null;\n }\n }\n\n const rows = await tx\n .update(jobExecutions)\n .set({\n status,\n statusReason,\n ...(outputs === undefined ? {} : {outputs}),\n version: sql`${jobExecutions.version} + 1`,\n updatedAt: new Date(),\n ...(params.markTimedOut ? {timedOutAt: new Date()} : {}),\n ...(TERMINAL_EXECUTION_STATUSES.includes(status) ? {finishedAt: sql`now()`} : {}),\n })\n .where(\n and(\n eq(jobExecutions.id, params.jobExecutionId),\n eq(jobExecutions.version, params.expectedVersion),\n notInArray(jobExecutions.status, TERMINAL_EXECUTION_STATUSES),\n ),\n )\n .returning();\n\n const row = rows[0];\n if (!row) return null;\n return {execution: toJobExecution(row), changed: true};\n}\n\nexport interface UpdateJobExecutionStatusParams {\n jobExecutionId: string;\n status: JobExecutionStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}\n\nexport async function updateJobExecutionStatus(\n params: UpdateJobExecutionStatusParams,\n): Promise<JobExecution> {\n const statusReason = params.statusReason ?? null;\n const result = await db().transaction(async (tx) => {\n return await optimisticLockRetry({\n updateFn: () =>\n updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: params.status,\n expectedVersion: params.expectedVersion,\n statusReason,\n secrets: params.secrets,\n }),\n fetchFn: async () => {\n const row = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n return row ? toJobExecution(row) : undefined;\n },\n matchFn: (execution) =>\n (execution.status === params.status && execution.statusReason === statusReason) ||\n TERMINAL_EXECUTION_STATUSES.includes(execution.status)\n ? {execution, changed: false}\n : null,\n failureMessage: `Optimistic lock failure: job execution ${params.jobExecutionId} version ${params.expectedVersion}`,\n });\n });\n\n if (result.changed) recordWorkflowJobExecutionStatusChanged(result.execution.status);\n\n return result.execution;\n}\n\nexport async function recordJobExecutionQueuedAt(params: {\n jobExecutionId: string;\n queuedAt: Date;\n}): Promise<void> {\n const updated = await db()\n .update(jobExecutions)\n .set({queuedAt: params.queuedAt})\n .where(and(eq(jobExecutions.id, params.jobExecutionId), isNull(jobExecutions.queuedAt)))\n .returning({id: jobExecutions.id});\n\n if (updated.length > 0) recordWorkflowJobExecutionQueued();\n}\n\nexport async function recordJobExecutionStartedAt(params: {\n jobExecutionId: string;\n startedAt: Date;\n}): Promise<void> {\n const updated = await db()\n .update(jobExecutions)\n .set({startedAt: params.startedAt})\n .where(and(eq(jobExecutions.id, params.jobExecutionId), isNull(jobExecutions.startedAt)))\n .returning({id: jobExecutions.id});\n\n if (updated.length > 0) recordWorkflowJobExecutionStarted();\n}\n\nexport async function failJobExecutionAsTimedOut(params: {\n jobExecutionId: string;\n workflowRunAttemptId: string;\n expectedVersion: number;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}): Promise<JobExecution> {\n const result = await db().transaction(async (tx) => {\n const updated = await optimisticLockRetry({\n updateFn: () =>\n updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: 'failed',\n expectedVersion: params.expectedVersion,\n statusReason: 'timed_out',\n markTimedOut: true,\n secrets: params.secrets,\n }),\n fetchFn: async () => {\n const row = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n return row ? toJobExecution(row) : undefined;\n },\n matchFn: (execution) => (execution.timedOutAt !== null ? {execution, changed: false} : null),\n failureMessage: `Optimistic lock failure: job execution ${params.jobExecutionId} version ${params.expectedVersion}`,\n });\n\n if (updated.changed) {\n const identity = await getWorkflowContextForJob(updated.execution.jobId, tx);\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_EXECUTION_TIMED_OUT,\n payload: {\n jobId: identity.jobId,\n jobExecutionId: params.jobExecutionId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n },\n });\n }\n\n return updated;\n });\n\n if (result.changed) {\n recordWorkflowJobExecutionStatusChanged(result.execution.status);\n recordWorkflowJobExecutionTimedOut();\n }\n\n return result.execution;\n}\n\nexport async function resolveJobExecutionAfterLeaseExpiry(params: {\n jobExecutionId: string;\n expectedVersion: number;\n secrets?: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'> | undefined;\n}): Promise<{status: RuntimeCompletionStatus; executionVersion: number}> {\n const result = await db().transaction(async (tx) => {\n const jobExecutionSteps = await getStepsByJobExecutionIdForUpdate(params.jobExecutionId, tx);\n let changedJobExecution: JobExecution | null = null;\n\n if (jobExecutionSteps.length === 0) {\n throw new JobNotFoundError(params.jobExecutionId);\n }\n\n if (jobExecutionSteps.every((step) => isTerminal(step.status))) {\n const status = deriveCompletion(jobExecutionSteps);\n const updated = await updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status,\n expectedVersion: params.expectedVersion,\n statusReason: statusReasonForStepCompletion(status),\n secrets: params.secrets,\n });\n changedJobExecution = updated?.changed ? updated.execution : null;\n } else {\n const updated = await updateJobExecutionStatusAtVersion(tx, {\n jobExecutionId: params.jobExecutionId,\n status: 'failed',\n expectedVersion: params.expectedVersion,\n statusReason: 'runner_lost',\n secrets: params.secrets,\n });\n if (updated?.changed) {\n changedJobExecution = updated.execution;\n await bulkUpdateStepStatuses(\n {jobExecutionId: params.jobExecutionId, status: 'cancelled'},\n tx,\n );\n }\n }\n\n const jobExecutionRow = (\n await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.id, params.jobExecutionId))\n .limit(1)\n )[0];\n if (!jobExecutionRow) {\n throw new Error(`Job execution not found resolving lease expiry: ${params.jobExecutionId}`);\n }\n const status: RuntimeCompletionStatus =\n jobExecutionRow.status === 'succeeded' ? 'succeeded' : 'failed';\n return {status, executionVersion: jobExecutionRow.version, changedJobExecution};\n });\n\n recordWorkflowJobExecutionLeaseExpiryResolved(result.status);\n if (result.changedJobExecution) {\n recordWorkflowJobExecutionStatusChanged(result.changedJobExecution.status);\n }\n\n return {status: result.status, executionVersion: result.executionVersion};\n}\n\nfunction statusReasonForStepCompletion(status: RuntimeCompletionStatus): JobStatusReason | null {\n return status === 'failed' ? 'step_failed' : null;\n}\n"],"names":["readPersistedWorkflowModel","WORKFLOWS_JOB_EXECUTION_TIMED_OUT","and","asc","desc","eq","isNull","notInArray","sql","InterpolationUnresolvableError","JobNotFoundError","deriveJobExecutionOutputs","deriveCompletion","isTerminal","recordWorkflowJobExecutionLeaseExpiryResolved","recordWorkflowJobExecutionQueued","recordWorkflowJobExecutionStarted","recordWorkflowJobExecutionStatusChanged","recordWorkflowJobExecutionTimedOut","db","writeWorkflowsOutboxEvent","jobExecutions","toJobExecution","jobs","toJob","stepAttempts","toStepAttempt","steps","toStep","workflowRunAttempts","toWorkflowRun","workflowRuns","getDirectDependencyJobContexts","loadReferencedVariables","getWorkflowContextForJob","optimisticLockRetry","TERMINAL_EXECUTION_STATUSES","bulkUpdateStepStatuses","getStepsByJobExecutionIdForUpdate","getJobExecutionById","id","tx","rows","select","from","where","limit","row","undefined","getJobExecutionsByWorkflowRunAttemptId","workflowRunAttemptId","jobExecution","innerJoin","jobId","orderBy","sequence","map","getJobExecutionsByJobId","getFirstJobExecutionByJobId","getLatestJobExecutionByJobId","resolveJobExecutionOutputs","params","target","execution","job","attempt","run","workflowRunId","jobExecutionId","model","modelJob","find","key","outputs","executionRows","executions","status","statusReason","stepRows","position","attemptRows","executionOrder","dependencyJobs","attempts","vars","workspaceId","projectId","definitionId","secrets","updateJobExecutionStatusAtVersion","includes","error","update","set","version","updatedAt","Date","markTimedOut","timedOutAt","finishedAt","expectedVersion","returning","changed","updateJobExecutionStatus","result","transaction","updateFn","fetchFn","matchFn","failureMessage","recordJobExecutionQueuedAt","updated","queuedAt","length","recordJobExecutionStartedAt","startedAt","failJobExecutionAsTimedOut","identity","type","payload","resolveJobExecutionAfterLeaseExpiry","jobExecutionSteps","changedJobExecution","every","step","statusReasonForStepCompletion","jobExecutionRow","Error","executionVersion"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,+BAA+B;AAExE,SAAQC,iCAAiC,QAAO,6BAA6B;AAC7E,SAAQC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,QAAO,cAAc;AAGxE,SAAQC,8BAA8B,EAAEC,gBAAgB,QAAO,kBAAkB;AACjF,SAAQC,yBAAyB,QAAO,gCAAgC;AACxE,SAAQC,gBAAgB,EAAEC,UAAU,QAAO,kDAAkD;AAE7F,SACEC,6CAA6C,EAC7CC,gCAAgC,EAChCC,iCAAiC,EACjCC,uCAAuC,EACvCC,kCAAkC,QAC7B,uBAAuB;AAC9B,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9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gD,EAAElE,OAAOO,cAAc,EAAE;QAC5F;QACA,MAAMQ,SACJkD,gBAAgBlD,MAAM,KAAK,cAAc,cAAc;QACzD,OAAO;YAACA;YAAQoD,kBAAkBF,gBAAgBhC,OAAO;YAAE4B;QAAmB;IAChF;IAEA5G,8CAA8C0F,OAAO5B,MAAM;IAC3D,IAAI4B,OAAOkB,mBAAmB,EAAE;QAC9BzG,wCAAwCuF,OAAOkB,mBAAmB,CAAC9C,MAAM;IAC3E;IAEA,OAAO;QAACA,QAAQ4B,OAAO5B,MAAM;QAAEoD,kBAAkBxB,OAAOwB,gBAAgB;IAAA;AAC1E;AAEA,SAASH,8BAA8BjD,MAA+B;IACpE,OAAOA,WAAW,WAAW,gBAAgB;AAC/C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { UpdateJobExecutionStatusAtVersionParams, UpdateJobExecutionStatusParams, } from './workflow-runs/job-executions.js';
|
|
2
|
-
export { failJobExecutionAsTimedOut, getFirstJobExecutionByJobId, getJobExecutionById, getJobExecutionsByJobId, getJobExecutionsByWorkflowRunAttemptId, getLatestJobExecutionByJobId,
|
|
2
|
+
export { failJobExecutionAsTimedOut, getFirstJobExecutionByJobId, getJobExecutionById, getJobExecutionsByJobId, getJobExecutionsByWorkflowRunAttemptId, getLatestJobExecutionByJobId, recordJobExecutionQueuedAt, recordJobExecutionStartedAt, resolveJobExecutionAfterLeaseExpiry, updateJobExecutionStatus, } from './workflow-runs/job-executions.js';
|
|
3
3
|
export type { EvaluateJobActivationsParams, EvaluateJobSuccessResult, JobActivationDecision, JobScope, UpdateJobStatusAtVersionParams, UpdateJobStatusParams, } from './workflow-runs/jobs.js';
|
|
4
4
|
export { evaluateJobActivations, evaluateJobSuccess, getDirectDependencyJobContexts, getJobById, getJobScope, getJobsByWorkflowRunAttemptId, getJobsByWorkflowRunId, resolveJobStatusFromJobExecutions, updateJobStatus, updateJobStatusAtVersion, } from './workflow-runs/jobs.js';
|
|
5
5
|
export { writeJobStepsSettledOutbox, writeStepAttemptTerminatedOutbox, writeStepRestartEnqueuedOutbox, } from './workflow-runs/outbox.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runs.d.ts","sourceRoot":"","sources":["../../src/db/workflow-runs.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uCAAuC,EACvC,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,sCAAsC,EACtC,4BAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"workflow-runs.d.ts","sourceRoot":"","sources":["../../src/db/workflow-runs.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uCAAuC,EACvC,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,sCAAsC,EACtC,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,8BAA8B,EAC9B,UAAU,EACV,WAAW,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,+BAA+B,EAC/B,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,qCAAqC,EACrC,uBAAuB,EACvB,8BAA8B,EAC9B,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EACjB,eAAe,EACf,+BAA+B,EAC/B,uBAAuB,EACvB,WAAW,EACX,0BAA0B,EAC1B,wBAAwB,EACxB,iCAAiC,EACjC,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
|
package/dist/db/workflow-runs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { failJobExecutionAsTimedOut, getFirstJobExecutionByJobId, getJobExecutionById, getJobExecutionsByJobId, getJobExecutionsByWorkflowRunAttemptId, getLatestJobExecutionByJobId,
|
|
1
|
+
export { failJobExecutionAsTimedOut, getFirstJobExecutionByJobId, getJobExecutionById, getJobExecutionsByJobId, getJobExecutionsByWorkflowRunAttemptId, getLatestJobExecutionByJobId, recordJobExecutionQueuedAt, recordJobExecutionStartedAt, resolveJobExecutionAfterLeaseExpiry, updateJobExecutionStatus } from './workflow-runs/job-executions.js';
|
|
2
2
|
export { evaluateJobActivations, evaluateJobSuccess, getDirectDependencyJobContexts, getJobById, getJobScope, getJobsByWorkflowRunAttemptId, getJobsByWorkflowRunId, resolveJobStatusFromJobExecutions, updateJobStatus, updateJobStatusAtVersion } from './workflow-runs/jobs.js';
|
|
3
3
|
export { writeJobStepsSettledOutbox, writeStepAttemptTerminatedOutbox, writeStepRestartEnqueuedOutbox } from './workflow-runs/outbox.js';
|
|
4
4
|
export { buildWorkflowRunListConditions, getJobExecutionDetail, getLatestAttempt, getWorkflowJobExecutionDepth, getWorkflowRunAggregates, getWorkflowRunAttemptById, getWorkflowRunByAttemptId, getWorkflowRunById, getWorkflowRunDetail, listRunAttempts, listWorkflowRuns, listWorkflowRunsByProject } from './workflow-runs/queries.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/workflow-runs.ts"],"sourcesContent":["export type {\n UpdateJobExecutionStatusAtVersionParams,\n UpdateJobExecutionStatusParams,\n} from './workflow-runs/job-executions.js';\nexport {\n failJobExecutionAsTimedOut,\n getFirstJobExecutionByJobId,\n getJobExecutionById,\n getJobExecutionsByJobId,\n getJobExecutionsByWorkflowRunAttemptId,\n getLatestJobExecutionByJobId,\n
|
|
1
|
+
{"version":3,"sources":["../../src/db/workflow-runs.ts"],"sourcesContent":["export type {\n UpdateJobExecutionStatusAtVersionParams,\n UpdateJobExecutionStatusParams,\n} from './workflow-runs/job-executions.js';\nexport {\n failJobExecutionAsTimedOut,\n getFirstJobExecutionByJobId,\n getJobExecutionById,\n getJobExecutionsByJobId,\n getJobExecutionsByWorkflowRunAttemptId,\n getLatestJobExecutionByJobId,\n recordJobExecutionQueuedAt,\n recordJobExecutionStartedAt,\n resolveJobExecutionAfterLeaseExpiry,\n updateJobExecutionStatus,\n} from './workflow-runs/job-executions.js';\nexport type {\n EvaluateJobActivationsParams,\n EvaluateJobSuccessResult,\n JobActivationDecision,\n JobScope,\n UpdateJobStatusAtVersionParams,\n UpdateJobStatusParams,\n} from './workflow-runs/jobs.js';\nexport {\n evaluateJobActivations,\n evaluateJobSuccess,\n getDirectDependencyJobContexts,\n getJobById,\n getJobScope,\n getJobsByWorkflowRunAttemptId,\n getJobsByWorkflowRunId,\n resolveJobStatusFromJobExecutions,\n updateJobStatus,\n updateJobStatusAtVersion,\n} from './workflow-runs/jobs.js';\nexport {\n writeJobStepsSettledOutbox,\n writeStepAttemptTerminatedOutbox,\n writeStepRestartEnqueuedOutbox,\n} from './workflow-runs/outbox.js';\nexport type {\n ListWorkflowRunsParams,\n ListWorkflowRunsResult,\n WorkflowJobExecutionDepth,\n WorkflowJobExecutionDepthParams,\n WorkflowRunAggregates,\n WorkflowRunCursor,\n WorkflowRunFilters,\n} from './workflow-runs/queries.js';\nexport {\n buildWorkflowRunListConditions,\n getJobExecutionDetail,\n getLatestAttempt,\n getWorkflowJobExecutionDepth,\n getWorkflowRunAggregates,\n getWorkflowRunAttemptById,\n getWorkflowRunByAttemptId,\n getWorkflowRunById,\n getWorkflowRunDetail,\n listRunAttempts,\n listWorkflowRuns,\n listWorkflowRunsByProject,\n} from './workflow-runs/queries.js';\nexport type {\n CancelWorkflowRunParams,\n CreateRerunWorkflowRunParams,\n CreateWorkflowRunParams,\n FailWorkflowRunAsTimedOutParams,\n UpdateWorkflowRunStatusParams,\n} from './workflow-runs/runs.js';\nexport {\n cancelWorkflowRun,\n createRerunWorkflowRun,\n createWorkflowRun,\n failWorkflowRunAsTimedOut,\n updateWorkflowRunStatus,\n} from './workflow-runs/runs.js';\nexport type {\n ApplyStepResultParams,\n BulkUpdateStepStatusesParams,\n CancelRemainingStepsParams,\n DispatchStepWithCompletedConfigParams,\n FinishStepAttemptParams,\n InsertRunningStepAttemptParams,\n MarkStepRunningParams,\n MarkStepSkippedParams,\n RewindStepsToPendingParams,\n} from './workflow-runs/steps.js';\nexport {\n applyStepResult,\n bulkUpdateStepStatuses,\n cancelRemainingSteps,\n countStepAttempts,\n dispatchStepWithCompletedConfig,\n finishStepAttempt,\n getStepAttempts,\n getStepAttemptsByJobExecutionId,\n getStepAttemptsByJobIds,\n getStepById,\n getStepByIdForJobExecution,\n getStepsByJobExecutionId,\n getStepsByJobExecutionIdForUpdate,\n getStepsByJobId,\n insertRunningStepAttempt,\n markStepRunning,\n markStepSkipped,\n rewindStepsToPending,\n settleJobFailed,\n} from './workflow-runs/steps.js';\n"],"names":["failJobExecutionAsTimedOut","getFirstJobExecutionByJobId","getJobExecutionById","getJobExecutionsByJobId","getJobExecutionsByWorkflowRunAttemptId","getLatestJobExecutionByJobId","recordJobExecutionQueuedAt","recordJobExecutionStartedAt","resolveJobExecutionAfterLeaseExpiry","updateJobExecutionStatus","evaluateJobActivations","evaluateJobSuccess","getDirectDependencyJobContexts","getJobById","getJobScope","getJobsByWorkflowRunAttemptId","getJobsByWorkflowRunId","resolveJobStatusFromJobExecutions","updateJobStatus","updateJobStatusAtVersion","writeJobStepsSettledOutbox","writeStepAttemptTerminatedOutbox","writeStepRestartEnqueuedOutbox","buildWorkflowRunListConditions","getJobExecutionDetail","getLatestAttempt","getWorkflowJobExecutionDepth","getWorkflowRunAggregates","getWorkflowRunAttemptById","getWorkflowRunByAttemptId","getWorkflowRunById","getWorkflowRunDetail","listRunAttempts","listWorkflowRuns","listWorkflowRunsByProject","cancelWorkflowRun","createRerunWorkflowRun","createWorkflowRun","failWorkflowRunAsTimedOut","updateWorkflowRunStatus","applyStepResult","bulkUpdateStepStatuses","cancelRemainingSteps","countStepAttempts","dispatchStepWithCompletedConfig","finishStepAttempt","getStepAttempts","getStepAttemptsByJobExecutionId","getStepAttemptsByJobIds","getStepById","getStepByIdForJobExecution","getStepsByJobExecutionId","getStepsByJobExecutionIdForUpdate","getStepsByJobId","insertRunningStepAttempt","markStepRunning","markStepSkipped","rewindStepsToPending","settleJobFailed"],"mappings":"AAIA,SACEA,0BAA0B,EAC1BC,2BAA2B,EAC3BC,mBAAmB,EACnBC,uBAAuB,EACvBC,sCAAsC,EACtCC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,mCAAmC,EACnCC,wBAAwB,QACnB,oCAAoC;AAS3C,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,UAAU,EACVC,WAAW,EACXC,6BAA6B,EAC7BC,sBAAsB,EACtBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,QACnB,0BAA0B;AACjC,SACEC,0BAA0B,EAC1BC,gCAAgC,EAChCC,8BAA8B,QACzB,4BAA4B;AAUnC,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,gBAAgB,EAChBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB,EACzBC,kBAAkB,EAClBC,oBAAoB,EACpBC,eAAe,EACfC,gBAAgB,EAChBC,yBAAyB,QACpB,6BAA6B;AAQpC,SACEC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,EACjBC,yBAAyB,EACzBC,uBAAuB,QAClB,0BAA0B;AAYjC,SACEC,eAAe,EACfC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,+BAA+B,EAC/BC,iBAAiB,EACjBC,eAAe,EACfC,+BAA+B,EAC/BC,uBAAuB,EACvBC,WAAW,EACXC,0BAA0B,EAC1BC,wBAAwB,EACxBC,iCAAiC,EACjCC,eAAe,EACfC,wBAAwB,EACxBC,eAAe,EACfC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,QACV,2BAA2B"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {\n RUNNER_JOB_CLAIMED,\n RUNNER_JOB_LEASE_EXPIRED,\n RUNNER_JOB_QUEUED,\n type RunnersEventMap,\n} from '@shipfox/api-runners-dto';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {\n WORKFLOWS_JOB_EVENT_DELIVERED,\n WORKFLOWS_JOB_STEPS_SETTLED,\n WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,\n WORKFLOWS_WORKFLOW_RUN_CANCELLED,\n type WorkflowsEventMapDto,\n workflowsEventSchemas,\n} from '@shipfox/api-workflows-dto';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {db, migrationsPath, workflowsOutbox} from '#db/index.js';\nimport {registerWorkflowsServiceMetrics} from '#metrics/index.js';\nimport {\n createWorkflowRoutes,\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n} from '#presentation/index.js';\nimport {createWorkflowsInterModulePresentation} from '#presentation/inter-module.js';\nimport {createOrchestrationActivities, WORKFLOWS_TASK_QUEUE} from '#temporal/index.js';\n\nexport type {\n Job,\n JobListenerEvent,\n JobListenerEventDisposition,\n RunWorkflowParams,\n Step,\n TriggerPayload,\n WorkflowRun,\n WorkflowSourceSnapshot,\n} from '#core/index.js';\nexport {\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n isPermanentRunWorkflowError,\n ProjectMismatchError,\n runWorkflow,\n WorkflowRunNotCancellableError,\n} from '#core/index.js';\nexport {\n closeDb,\n type DeliverEventToListenerParams,\n type DeliverEventToListenerResult,\n db,\n deliverEventToListener,\n getStepById,\n getStepByIdForJobExecution,\n migrationsPath,\n workflowsOutbox,\n} from '#db/index.js';\nexport {loadRunningLeasedStep} from '#presentation/routes/leased-step.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<WorkflowsEventMapDto & RunnersEventMap>();\n\nexport function createWorkflowsModule({\n agent,\n definitions,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n}: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n runners: RunnersInterModuleClient;\n secrets: SecretsInterModuleClient;\n}): ShipfoxModule {\n return {\n name: 'workflows',\n database: {db, migrationsPath},\n routes: createWorkflowRoutes({\n agent,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n }),\n metrics: registerWorkflowsServiceMetrics,\n publishers: [\n {name: 'workflows', table: workflowsOutbox, db, eventSchemas: workflowsEventSchemas},\n ],\n subscribers: [\n subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),\n subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),\n subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),\n subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),\n subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),\n subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),\n subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed),\n ],\n workers: [\n {\n taskQueue: WORKFLOWS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createOrchestrationActivities({agent, integrations, projects, runners, secrets}),\n workflows: [],\n },\n ],\n interModulePresentations: [\n createWorkflowsInterModulePresentation({\n agent,\n definitions,\n integrations,\n projects,\n runners,\n secrets,\n }),\n ],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","RUNNER_JOB_CLAIMED","RUNNER_JOB_LEASE_EXPIRED","RUNNER_JOB_QUEUED","WORKFLOWS_JOB_EVENT_DELIVERED","WORKFLOWS_JOB_STEPS_SETTLED","WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED","WORKFLOWS_WORKFLOW_RUN_CANCELLED","workflowsEventSchemas","subscriberFactory","db","migrationsPath","workflowsOutbox","registerWorkflowsServiceMetrics","createWorkflowRoutes","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled","createWorkflowsInterModulePresentation","createOrchestrationActivities","WORKFLOWS_TASK_QUEUE","DefinitionNotFoundError","InterpolationUnresolvableError","isPermanentRunWorkflowError","ProjectMismatchError","runWorkflow","WorkflowRunNotCancellableError","closeDb","deliverEventToListener","getStepById","getStepByIdForJobExecution","loadRunningLeasedStep","packageRoot","url","workflowsPath","subscriber","createWorkflowsModule","agent","definitions","annotations","auth","integrations","projects","runners","secrets","name","database","routes","metrics","publishers","table","eventSchemas","subscribers","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAOvC,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,iBAAiB,QAEZ,2BAA2B;AAGlC,SACEC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,sCAAsC,EACtCC,gCAAgC,EAEhCC,qBAAqB,QAChB,6BAA6B;AACpC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,EAAE,EAAEC,cAAc,EAAEC,eAAe,QAAO,eAAe;AACjE,SAAQC,+BAA+B,QAAO,oBAAoB;AAClE,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,QACjB,yBAAyB;AAChC,SAAQC,sCAAsC,QAAO,gCAAgC;AACrF,SAAQC,6BAA6B,EAAEC,oBAAoB,QAAO,qBAAqB;AAYvF,SACEC,uBAAuB,EACvBC,8BAA8B,EAC9BC,2BAA2B,EAC3BC,oBAAoB,EACpBC,WAAW,EACXC,8BAA8B,QACzB,iBAAiB;AACxB,SACEC,OAAO,EAGPrB,EAAE,EACFsB,sBAAsB,EACtBC,WAAW,EACXC,0BAA0B,EAC1BvB,cAAc,EACdC,eAAe,QACV,eAAe;AACtB,SAAQuB,qBAAqB,QAAO,sCAAsC;AAE1E,MAAMC,cAAcrC,QAAQD,QAAQE,cAAc,YAAYqC,GAAG,IAAI;AACrE,MAAMC,gBAAgBvC,QAAQqC,aAAa;AAE3C,MAAMG,aAAa9B;AAEnB,OAAO,SAAS+B,sBAAsB,EACpCC,KAAK,EACLC,WAAW,EACXC,WAAW,EACXC,IAAI,EACJC,YAAY,EACZC,QAAQ,EACRC,OAAO,EACPC,OAAO,EAUR;IACC,OAAO;QACLC,MAAM;QACNC,UAAU;YAACxC;YAAIC;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {DefinitionsInterModuleClient} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {\n RUNNER_JOB_CLAIMED,\n RUNNER_JOB_LEASE_EXPIRED,\n RUNNER_JOB_QUEUED,\n type RunnersEventMap,\n} from '@shipfox/api-runners-dto';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport {\n WORKFLOWS_JOB_EVENT_DELIVERED,\n WORKFLOWS_JOB_STEPS_SETTLED,\n WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,\n WORKFLOWS_WORKFLOW_RUN_CANCELLED,\n type WorkflowsEventMapDto,\n workflowsEventSchemas,\n} from '@shipfox/api-workflows-dto';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {db, migrationsPath, workflowsOutbox} from '#db/index.js';\nimport {registerWorkflowsServiceMetrics} from '#metrics/index.js';\nimport {\n createWorkflowRoutes,\n onJobEventDelivered,\n onJobStepsSettled,\n onRunnerJobClaimed,\n onRunnerJobLeaseExpired,\n onRunnerJobQueued,\n onWorkflowRunAttemptCreated,\n onWorkflowRunCancelled,\n} from '#presentation/index.js';\nimport {createWorkflowsInterModulePresentation} from '#presentation/inter-module.js';\nimport {createOrchestrationActivities, WORKFLOWS_TASK_QUEUE} from '#temporal/index.js';\n\nexport type {\n Job,\n JobListenerEvent,\n JobListenerEventDisposition,\n RunWorkflowParams,\n Step,\n TriggerPayload,\n WorkflowRun,\n WorkflowSourceSnapshot,\n} from '#core/index.js';\nexport {\n DefinitionNotFoundError,\n InterpolationUnresolvableError,\n isPermanentRunWorkflowError,\n ProjectMismatchError,\n runWorkflow,\n WorkflowRunNotCancellableError,\n} from '#core/index.js';\nexport {\n closeDb,\n type DeliverEventToListenerParams,\n type DeliverEventToListenerResult,\n db,\n deliverEventToListener,\n getStepById,\n getStepByIdForJobExecution,\n migrationsPath,\n workflowsOutbox,\n} from '#db/index.js';\nexport {loadRunningLeasedStep} from '#presentation/routes/leased-step.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<WorkflowsEventMapDto & RunnersEventMap>();\n\nexport function createWorkflowsModule({\n agent,\n definitions,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n}: {\n agent: AgentInterModuleClient;\n definitions: DefinitionsInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n runners: RunnersInterModuleClient;\n secrets: SecretsInterModuleClient;\n}): ShipfoxModule {\n return {\n name: 'workflows',\n database: {db, migrationsPath, databaseNamespace: 'workflows'},\n routes: createWorkflowRoutes({\n agent,\n annotations,\n auth,\n integrations,\n projects,\n runners,\n secrets,\n }),\n metrics: registerWorkflowsServiceMetrics,\n publishers: [\n {name: 'workflows', table: workflowsOutbox, db, eventSchemas: workflowsEventSchemas},\n ],\n subscribers: [\n subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),\n subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),\n subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),\n subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),\n subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),\n subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),\n subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed),\n ],\n workers: [\n {\n taskQueue: WORKFLOWS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createOrchestrationActivities({agent, integrations, projects, runners, secrets}),\n workflows: [],\n },\n ],\n interModulePresentations: [\n createWorkflowsInterModulePresentation({\n agent,\n definitions,\n integrations,\n projects,\n runners,\n secrets,\n }),\n ],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","RUNNER_JOB_CLAIMED","RUNNER_JOB_LEASE_EXPIRED","RUNNER_JOB_QUEUED","WORKFLOWS_JOB_EVENT_DELIVERED","WORKFLOWS_JOB_STEPS_SETTLED","WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED","WORKFLOWS_WORKFLOW_RUN_CANCELLED","workflowsEventSchemas","subscriberFactory","db","migrationsPath","workflowsOutbox","registerWorkflowsServiceMetrics","createWorkflowRoutes","onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled","createWorkflowsInterModulePresentation","createOrchestrationActivities","WORKFLOWS_TASK_QUEUE","DefinitionNotFoundError","InterpolationUnresolvableError","isPermanentRunWorkflowError","ProjectMismatchError","runWorkflow","WorkflowRunNotCancellableError","closeDb","deliverEventToListener","getStepById","getStepByIdForJobExecution","loadRunningLeasedStep","packageRoot","url","workflowsPath","subscriber","createWorkflowsModule","agent","definitions","annotations","auth","integrations","projects","runners","secrets","name","database","databaseNamespace","routes","metrics","publishers","table","eventSchemas","subscribers","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAOvC,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,iBAAiB,QAEZ,2BAA2B;AAGlC,SACEC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,sCAAsC,EACtCC,gCAAgC,EAEhCC,qBAAqB,QAChB,6BAA6B;AACpC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,EAAE,EAAEC,cAAc,EAAEC,eAAe,QAAO,eAAe;AACjE,SAAQC,+BAA+B,QAAO,oBAAoB;AAClE,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,2BAA2B,EAC3BC,sBAAsB,QACjB,yBAAyB;AAChC,SAAQC,sCAAsC,QAAO,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mB;gBACAC;gBACAG;gBACAC;gBACAC;gBACAC;YACF;SACD;IACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/next-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,uCAAuC,CAAC;AACxF,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,wBAAwB,CAAC;CACnC,
|
|
1
|
+
{"version":3,"file":"next-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/next-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,uCAAuC,CAAC;AACxF,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,wBAAwB,CAAC;CACnC,mDAoEA"}
|
|
@@ -2,7 +2,7 @@ import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
|
2
2
|
import { nextStepResponseSchema } from '@shipfox/api-workflows-dto';
|
|
3
3
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
4
|
import { warnAgentToolCapabilityMismatchOnDispatch } from '#core/agent-tool-capability-warning.js';
|
|
5
|
-
import {
|
|
5
|
+
import { JobNotFoundError } from '#core/errors.js';
|
|
6
6
|
import { nextStepForLeasedJobExecution } from '#core/job-execution.js';
|
|
7
7
|
import { toStepDto } from '#presentation/dto/step.js';
|
|
8
8
|
export function createNextStepRoute(params) {
|
|
@@ -21,19 +21,22 @@ export function createNextStepRoute(params) {
|
|
|
21
21
|
status: 404
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
if (error instanceof JobLeaseNotActiveError) {
|
|
25
|
-
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
26
|
-
status: 404
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
24
|
throw error;
|
|
30
25
|
},
|
|
31
26
|
handler: async (request)=>{
|
|
32
27
|
const leasedJob = requireLeasedJobContext(request);
|
|
33
|
-
const
|
|
28
|
+
const { active: leaseIsActive } = await params.runners.getLeaseState({
|
|
34
29
|
jobId: leasedJob.jobId,
|
|
35
30
|
jobExecutionId: leasedJob.jobExecutionId,
|
|
36
|
-
runnerSessionId: leasedJob.runnerSessionId
|
|
31
|
+
runnerSessionId: leasedJob.runnerSessionId
|
|
32
|
+
});
|
|
33
|
+
if (!leaseIsActive) {
|
|
34
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
35
|
+
status: 404
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const next = await nextStepForLeasedJobExecution({
|
|
39
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
37
40
|
agent: params.agent
|
|
38
41
|
});
|
|
39
42
|
if (next.kind === 'step') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/next-step.ts"],"sourcesContent":["import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport {nextStepResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {warnAgentToolCapabilityMismatchOnDispatch} from '#core/agent-tool-capability-warning.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/next-step.ts"],"sourcesContent":["import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport {nextStepResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {warnAgentToolCapabilityMismatchOnDispatch} from '#core/agent-tool-capability-warning.js';\nimport {JobNotFoundError} from '#core/errors.js';\nimport {nextStepForLeasedJobExecution} from '#core/job-execution.js';\nimport {toStepDto} from '#presentation/dto/step.js';\n\nexport function createNextStepRoute(params: {\n agent: AgentInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n runners: RunnersInterModuleClient;\n}) {\n return defineRoute({\n method: 'POST',\n path: '/steps/next',\n description:\n 'Returns the next step for the runner to run on its job. The job is identified by the access token, so no job ID is needed. Calling this again before reporting the current step returns that same step, so retries are safe. When no runnable steps remain, the response reports that there are no more steps to run, along with the job status; the runner then stops. Finalization is driven server-side from recorded step results and dispatch-time skips, not by the runner calling a job-completion endpoint.',\n schema: {\n response: {\n 200: nextStepResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof JobNotFoundError) {\n throw new ClientError(error.message, 'job-not-found', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const leasedJob = requireLeasedJobContext(request);\n const {active: leaseIsActive} = await params.runners.getLeaseState({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const next = await nextStepForLeasedJobExecution({\n jobExecutionId: leasedJob.jobExecutionId,\n agent: params.agent,\n });\n\n if (next.kind === 'step') {\n const {token: leaseToken} = await params.auth.mintJobLeaseToken({\n workflowRunId: leasedJob.workflowRunId,\n ...(leasedJob.workflowRunAttempt === undefined\n ? {}\n : {workflowRunAttempt: leasedJob.workflowRunAttempt}),\n workflowRunAttemptId: leasedJob.workflowRunAttemptId,\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n projectId: leasedJob.projectId,\n workspaceId: leasedJob.workspaceId,\n runnerSessionId: leasedJob.runnerSessionId,\n currentStepId: next.step.id,\n currentStepAttempt: next.step.currentAttempt,\n });\n if (next.dispatched) {\n await warnAgentToolCapabilityMismatchOnDispatch({\n annotations: params.annotations,\n runners: params.runners,\n leaseIdentity: leasedJob,\n step: next.step,\n });\n }\n // The runner echoes this back on report so a stale report from a superseded\n // attempt is ignored.\n return {\n kind: 'step' as const,\n step: toStepDto(next.step),\n attempt: next.step.currentAttempt,\n lease_token: leaseToken,\n };\n }\n return {kind: 'done' as const, status: next.status};\n },\n });\n}\n"],"names":["requireLeasedJobContext","nextStepResponseSchema","ClientError","defineRoute","warnAgentToolCapabilityMismatchOnDispatch","JobNotFoundError","nextStepForLeasedJobExecution","toStepDto","createNextStepRoute","params","method","path","description","schema","response","errorHandler","error","message","status","handler","request","leasedJob","active","leaseIsActive","runners","getLeaseState","jobId","jobExecutionId","runnerSessionId","next","agent","kind","token","leaseToken","auth","mintJobLeaseToken","workflowRunId","workflowRunAttempt","undefined","workflowRunAttemptId","projectId","workspaceId","currentStepId","step","id","currentStepAttempt","currentAttempt","dispatched","annotations","leaseIdentity","attempt","lease_token"],"mappings":"AAEA,SAAQA,uBAAuB,QAAO,4BAA4B;AAGlE,SAAQC,sBAAsB,QAAO,6BAA6B;AAClE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,yCAAyC,QAAO,yCAAyC;AACjG,SAAQC,gBAAgB,QAAO,kBAAkB;AACjD,SAAQC,6BAA6B,QAAO,yBAAyB;AACrE,SAAQC,SAAS,QAAO,4BAA4B;AAEpD,OAAO,SAASC,oBAAoBC,MAKnC;IACC,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aACE;QACFC,QAAQ;YACNC,UAAU;gBACR,KAAKb;YACP;QACF;QACAc,cAAc,CAACC;YACb,IAAIA,iBAAiBX,kBAAkB;gBACrC,MAAM,IAAIH,YAAYc,MAAMC,OAAO,EAAE,iBAAiB;oBAACC,QAAQ;gBAAG;YACpE;YACA,MAAMF;QACR;QACAG,SAAS,OAAOC;YACd,MAAMC,YAAYrB,wBAAwBoB;YAC1C,MAAM,EAACE,QAAQC,aAAa,EAAC,GAAG,MAAMd,OAAOe,OAAO,CAACC,aAAa,CAAC;gBACjEC,OAAOL,UAAUK,KAAK;gBACtBC,gBAAgBN,UAAUM,cAAc;gBACxCC,iBAAiBP,UAAUO,eAAe;YAC5C;YACA,IAAI,CAACL,eAAe;gBAClB,MAAM,IAAIrB,YAAY,iCAAiC,oBAAoB;oBAACgB,QAAQ;gBAAG;YACzF;YAEA,MAAMW,OAAO,MAAMvB,8BAA8B;gBAC/CqB,gBAAgBN,UAAUM,cAAc;gBACxCG,OAAOrB,OAAOqB,KAAK;YACrB;YAEA,IAAID,KAAKE,IAAI,KAAK,QAAQ;gBACxB,MAAM,EAACC,OAAOC,UAAU,EAAC,GAAG,MAAMxB,OAAOyB,IAAI,CAACC,iBAAiB,CAAC;oBAC9DC,eAAef,UAAUe,aAAa;oBACtC,GAAIf,UAAUgB,k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