diff --git a/packages/core/src/lib/runtime.test.ts b/packages/core/src/lib/runtime.test.ts index f169521..51d0574 100644 --- a/packages/core/src/lib/runtime.test.ts +++ b/packages/core/src/lib/runtime.test.ts @@ -1,6 +1,12 @@ import { describe, expect, it } from 'vitest'; -import type { EventEnvelope, WorkflowDefinition } from '@pulsestack/contracts'; +import type { + EventEnvelope, + ExecutionSnapshot, + TraceSpan, + WorkflowDefinition, +} from '@pulsestack/contracts'; +import type { PulseInfra } from './infra.js'; import { WorkflowRuntime } from './runtime.js'; class RuntimeInfraMock { @@ -43,15 +49,8 @@ describe('WorkflowRuntime', () => { ); expect(tenantEvents.length).toBeGreaterThan(0); expect(tenantEvents.every((event) => event.tenantId === workflow.tenantId)).toBe(true); - -import type { - EventEnvelope, - ExecutionSnapshot, - TraceSpan, -} from '@pulsestack/contracts'; -import { describe, expect, it } from 'vitest'; -import type { PulseInfra } from './infra.js'; -import { WorkflowRuntime } from './runtime.js'; + }); +}); function createRuntimeHarness() { const events: EventEnvelope[] = []; diff --git a/packages/core/src/lib/runtime.ts b/packages/core/src/lib/runtime.ts index e2bceda..18b077b 100644 --- a/packages/core/src/lib/runtime.ts +++ b/packages/core/src/lib/runtime.ts @@ -78,39 +78,6 @@ export class WorkflowRuntime { input: request.input, }); - const state: Record = { ...request.input }; - const results: StepResult[] = []; - - for (const [index, step] of request.workflow.steps.entries()) { - const span = await this.startSpan({ - traceId, - executionId, - workflowId: request.workflow.id, - tenantId: request.workflow.tenantId, - step, - state, - }); - - const result = await this.runStep(step, state, request.workflow.tenantId, request.workflow.correlationId); - Object.assign(state, { [step.id]: result.output }); - results.push(result); - - await this.snapshot({ - id: createId('snap'), - executionId, - workflowId: request.workflow.id, - sequence: index, - state: structuredClone(state), - sideEffects: [ - { - type: step.kind, - key: step.id, - response: result.output, - }, - ], - createdAt: new Date().toISOString(), - }); - await publishEvent( this.infra, createEvent({ @@ -157,6 +124,7 @@ export class WorkflowRuntime { traceId, executionId, workflowId: request.workflow.id, + tenantId: request.workflow.tenantId, parentSpanId: workflowSpanId, step, state, @@ -303,6 +271,7 @@ export class WorkflowRuntime { const result = await this.runStep( args.step, args.state, + args.tenantId, args.correlationId, attempt, ); @@ -368,9 +337,6 @@ export class WorkflowRuntime { tenantId: string, correlationId: string, - ): Promise { - - correlationId: string, attempt: number, ): Promise> {