From 74a96c0d159f20c1a9cd6f949b82fb2fd89a796d Mon Sep 17 00:00:00 2001 From: Richard R Date: Sat, 13 Jun 2026 14:18:45 -0600 Subject: [PATCH] refactor(compute-worker): improve docstore directory resolution logic Update resolveDocstoreDir to handle multiple environments: - Prefer monorepo root for local development - Check process.env.PWD for containerized bootstrap - Fallback to standard /app/docstore path - Default to process cwd Enhances robustness of docstore path resolution across deployment scenarios. --- .../compute-worker/src/infrastructure/platform.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/compute-worker/src/infrastructure/platform.ts b/packages/compute-worker/src/infrastructure/platform.ts index 9f029e4..3752a17 100644 --- a/packages/compute-worker/src/infrastructure/platform.ts +++ b/packages/compute-worker/src/infrastructure/platform.ts @@ -14,8 +14,23 @@ function findMonorepoRoot(startDir: string): string | null { } function resolveDocstoreDir(): string { + // 1. Try to find the monorepo root (works in local development) const repoRoot = findMonorepoRoot(process.cwd()); if (repoRoot) return path.join(repoRoot, 'docstore'); + + // 2. In a containerized environment, the parent bootstrap process runs in /app + // and the child process inherits process.env.PWD = '/app'. + if (process.env.PWD) { + const pwdDocstore = path.join(process.env.PWD, 'docstore'); + if (fs.existsSync(pwdDocstore)) return pwdDocstore; + } + + // 3. Fallback to the standard container app docstore path if it exists + if (fs.existsSync('/app/docstore')) { + return '/app/docstore'; + } + + // 4. Fallback to the process cwd docstore return path.join(process.cwd(), 'docstore'); }