From 61831ba7b8722d2cc868732e9df0bd753c2041a3 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:03:47 -0500 Subject: [PATCH] refactor: defer adapter launcher imports during workspace snapshots (#16492) Defer adapter launcher imports until a directory merge resolves its lock root. Snapshot-only workers retain the same hashes, modes, exclusions, and ownership checks. Verification: 63 focused cases; full typecheck/build; exact-head full CI/E2E/security; Apex 5/5. Local native Daytona replies: 66.939s cold and 26.485s warm. Hosted staging and the cold latency target remain unverified. Co-Authored-By: Paperclip --- doc/execution-semantics.md | 4 +++- packages/adapter-utils/src/workspace-restore-merge.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/execution-semantics.md b/doc/execution-semantics.md index 212a0d0663d..e2c160a225b 100644 --- a/doc/execution-semantics.md +++ b/doc/execution-semantics.md @@ -542,7 +542,9 @@ private manifest before handing it to the controller; ordinary snapshot disposal removes that worker's temporary directory. A failed capture removes its temporary state before releasing its worker slot. This scheduling boundary does not replace source authorization, warm-stamp validation, Git identity checks or restore -conflict detection. Legacy adapter snapshots remain inline. +conflict detection. Legacy adapter snapshots remain inline. Snapshot-only workers +do not load the adapter process-launch helpers. The directory merge loads those +helpers when it resolves its instance-scoped lock root. ### Remote Codex model compatibility diff --git a/packages/adapter-utils/src/workspace-restore-merge.ts b/packages/adapter-utils/src/workspace-restore-merge.ts index e35923638ae..7e1d2f9a485 100644 --- a/packages/adapter-utils/src/workspace-restore-merge.ts +++ b/packages/adapter-utils/src/workspace-restore-merge.ts @@ -5,7 +5,6 @@ import path from "node:path"; import { DatabaseSync } from "node:sqlite"; import { createWorkspaceManifest, WorkspaceManifestMap, workspacePathMatcher, type PathManifest, type WorkspacePaths, type WorkspaceManifestWriter } from "./workspace-manifest.js"; import { shouldExcludePath } from "./exclude-patterns.js"; -import { resolvePaperclipInstanceRootForAdapter } from "./server-utils.js"; import { runSnapshotThread } from "./workspace-snapshot-thread.js"; import type { WorkspaceRestoreDiagnostic } from "./workspace-restore-diagnostics.js"; @@ -493,6 +492,7 @@ function nonEmpty(value: string | undefined): string | null { * would follow the symlink) before any caller treats it as the lock root. */ async function resolveDirectoryMergeLockRoot(env: NodeJS.ProcessEnv = process.env): Promise { + const { resolvePaperclipInstanceRootForAdapter } = await import("./server-utils.js"); const instanceRoot = resolvePaperclipInstanceRootForAdapter({ homeDir: nonEmpty(env.PAPERCLIP_HOME) ?? undefined, instanceId: nonEmpty(env.PAPERCLIP_INSTANCE_ID) ?? undefined,