From 66619c7bd174d4feae0f681dbe664c65623cf87e Mon Sep 17 00:00:00 2001 From: Aseem Shrey Date: Sat, 7 Feb 2026 15:12:55 -0500 Subject: [PATCH] fix(worker): use deterministic volume naming for workflow execution Replace timestamp-based volume naming with deterministic names derived from tenantId and runId. This allows downstream components (scanners) to reference volumes created by upstream components (clone-repo) in the same workflow execution without passing volume names through the graph. Add static deriveVolumeName() method so any component can compute the expected volume name from context. Signed-off-by: Aseem Shrey --- worker/src/utils/isolated-volume.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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