mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 15:52:36 +01:00
Preserve in-place workspaces during Claude readiness config setup
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
8b3b221cc6
commit
387f1c7e2e
2 files changed
+53
-2
No files matched your search
@@ -166,6 +166,51 @@ describe("prepareSandboxClaudeProbeRuntime managed-config diagnostics", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("materializes config without syncing the persistent in-place workspace", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-claude-in-place-probe-"));
|
||||
cleanupDirs.push(root);
|
||||
const remoteRoot = "/home/user/paperclip/company/agents/agent";
|
||||
const target: AdapterExecutionTarget = {
|
||||
...sandboxTarget,
|
||||
workspaceRealization: {
|
||||
mode: "in_place",
|
||||
authoritativeRoot: remoteRoot,
|
||||
pathAliases: [],
|
||||
outboundRestorePaths: [],
|
||||
},
|
||||
};
|
||||
const restoreWorkspace = vi.fn(async () => {});
|
||||
prepareAdapterExecutionTargetRuntime.mockImplementationOnce(async (input) => {
|
||||
// Reproduce the production boundary: importing a host workspace would
|
||||
// overwrite remote authority. Only the selected config asset may stage.
|
||||
expect(input.syncWorkspace).toBe(false);
|
||||
expect(input.workspaceRemoteDir).toBe(remoteRoot);
|
||||
expect(input.assets).toEqual([{ key: "config-seed", localDir: root, followSymlinks: true }]);
|
||||
return {
|
||||
runtimeRootDir: `${remoteRoot}/.paperclip-runtime/claude`,
|
||||
assetDirs: { "config-seed": `${remoteRoot}/.paperclip-runtime/claude/config-seed` },
|
||||
restoreWorkspace,
|
||||
};
|
||||
});
|
||||
const env = { CLAUDE_CONFIG_DIR: root };
|
||||
const checks = await prepareSandboxClaudeProbeRuntime({
|
||||
managedAiConnection: true,
|
||||
runId: "run-in-place",
|
||||
target,
|
||||
cwd: remoteRoot,
|
||||
companyId: "company-1",
|
||||
env,
|
||||
installCommand: "install-claude",
|
||||
detectCommand: "claude",
|
||||
targetIsRemote: true,
|
||||
targetIsSandbox: true,
|
||||
helloProbeTimeoutSec: 30,
|
||||
});
|
||||
expect(checks).toEqual([expect.objectContaining({ code: "claude_managed_config_dir", level: "info" })]);
|
||||
expect(env.CLAUDE_CONFIG_DIR).toBe(`${remoteRoot}/.paperclip-runtime/claude/config`);
|
||||
expect(restoreWorkspace).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("keeps a thrown config-materialization error out of every check and the log", async () => {
|
||||
// The runtime preparation throws an error that carries two untrusted values:
|
||||
// an opaque credential marker and a proxy marker. Neither may reach a check
|
||||
|
||||
@@ -302,8 +302,11 @@ export async function prepareSandboxClaudeProbeRuntime(input: {
|
||||
let preparedRuntime: Awaited<ReturnType<typeof prepareAdapterExecutionTargetRuntime>> | null = null;
|
||||
try {
|
||||
const seedDir = input.managedAiConnection ? input.env.CLAUDE_CONFIG_DIR : await prepareClaudeConfigSeed(process.env, async () => {}, input.companyId);
|
||||
const managedRemoteCwd =
|
||||
input.target?.kind === "remote" ? input.target.remoteCwd : input.cwd;
|
||||
const workspaceRealization = input.target?.kind === "remote"
|
||||
? input.target.workspaceRealization : undefined;
|
||||
const managedRemoteCwd = workspaceRealization?.mode === "in_place"
|
||||
? workspaceRealization.authoritativeRoot
|
||||
: input.target?.kind === "remote" ? input.target.remoteCwd : input.cwd;
|
||||
tempWorkspaceDir = await fs.mkdtemp(
|
||||
path.join(os.tmpdir(), "paperclip-claude-envtest-workspace-"),
|
||||
);
|
||||
@@ -313,6 +316,9 @@ export async function prepareSandboxClaudeProbeRuntime(input: {
|
||||
adapterKey: "claude",
|
||||
workspaceLocalDir: tempWorkspaceDir,
|
||||
workspaceRemoteDir: managedRemoteCwd,
|
||||
// A readiness probe only stages config assets. In-place workspaces are
|
||||
// persistent authority and must never receive the empty probe workspace.
|
||||
syncWorkspace: workspaceRealization?.mode !== "in_place",
|
||||
timeoutSec: Math.max(1, input.helloProbeTimeoutSec),
|
||||
assets: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user