diff --git a/worker/src/utils/isolated-volume.ts b/worker/src/utils/isolated-volume.ts index 70c0cd26..53e35ee8 100644 --- a/worker/src/utils/isolated-volume.ts +++ b/worker/src/utils/isolated-volume.ts @@ -50,6 +50,19 @@ export class IsolatedContainerVolume { } } + /** + * Derives the deterministic volume name for a given tenant and run. + * Downstream components can use this to reference an existing volume + * created by an upstream component in the same workflow execution. + * + * @param tenantId - Tenant identifier + * @param runId - Unique run/execution identifier + * @returns The volume name (e.g., `tenant-foo-run-bar`) + */ + static deriveVolumeName(tenantId: string, runId: string): string { + return `tenant-${tenantId}-run-${runId}`; + } + /** * Creates the isolated volume and populates it with files. * @@ -72,9 +85,9 @@ export class IsolatedContainerVolume { }); } - // Create unique volume name with timestamp to prevent collisions - const timestamp = Date.now(); - this.volumeName = `tenant-${this.tenantId}-run-${this.runId}-${timestamp}`; + // Create deterministic volume name from tenantId + runId + // runId is unique per workflow execution, so no timestamp needed + this.volumeName = IsolatedContainerVolume.deriveVolumeName(this.tenantId, this.runId); try { // Create the volume with labels for tracking