diff --git a/package.json b/package.json index b0faac0..6e666d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "paperclip-adapter-claude-k8s", - "version": "0.2.0", + "version": "0.2.2", "description": "Paperclip adapter plugin that runs Claude Code agents as Kubernetes Jobs", "license": "MIT", "repository": { diff --git a/src/server/job-manifest.test.ts b/src/server/job-manifest.test.ts index 12bf8a7..6020000 100644 --- a/src/server/job-manifest.test.ts +++ b/src/server/job-manifest.test.ts @@ -301,8 +301,7 @@ describe("buildJobManifest", () => { const init = job.spec?.template?.spec?.initContainers?.[0]; expect(init?.command?.[0]).toBe("sh"); expect(init?.command?.[1]).toBe("-c"); - expect(init?.command?.[2]).toContain("mkdir -p /paperclip/instances/default/run-logs/"); - expect(init?.command?.[2]).toContain("printf '%s' \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"); + expect(init?.command?.[2]).toBe("printf '%s' \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"); }); it("write-prompt mounts prompt volume", () => { @@ -808,28 +807,26 @@ describe("buildJobManifest", () => { const { job } = buildJobManifest({ ctx, selfPod }); const cmd = job.spec?.template?.spec?.containers[0]?.command?.[2] ?? ""; expect(cmd).toContain("| tee"); - expect(cmd).toContain("/paperclip/instances/default/run-logs/"); + expect(cmd).toContain("/paperclip/instances/default/data/run-logs/"); }); it("podLogPath is returned from buildJobManifest", () => { const result = buildJobManifest({ ctx, selfPod }); expect(result.podLogPath).toBe( - "/paperclip/instances/default/run-logs/co1/agent-abc/run-abc12345.pod.ndjson", + "/paperclip/instances/default/data/run-logs/co1/agent-abc/run-abc12345.pod.ndjson", ); }); it("buildPodLogPath returns correctly formatted path", () => { expect(buildPodLogPath("co1", "agent-abc", "run-abc12345")).toBe( - "/paperclip/instances/default/run-logs/co1/agent-abc/run-abc12345.pod.ndjson", + "/paperclip/instances/default/data/run-logs/co1/agent-abc/run-abc12345.pod.ndjson", ); }); - it("init container creates log directory", () => { + it("init container does not create log directory (server pre-creates it on shared PVC)", () => { const { job } = buildJobManifest({ ctx, selfPod }); const initCmd = job.spec?.template?.spec?.initContainers?.[0]?.command; - expect(initCmd?.[0]).toBe("sh"); - expect(initCmd?.[1]).toBe("-c"); - expect(initCmd?.[2]).toContain("mkdir -p /paperclip/instances/default/run-logs/"); + expect(initCmd?.[2]).not.toContain("mkdir -p /paperclip"); }); it("sanitizes companyId with / to valid path component for log path", () => { diff --git a/src/server/job-manifest.ts b/src/server/job-manifest.ts index 1970edf..2469ce0 100644 --- a/src/server/job-manifest.ts +++ b/src/server/job-manifest.ts @@ -23,7 +23,7 @@ function sanitizeForK8sPath(value: string): string { } export function buildPodLogPath(companyId: string, agentId: string, runId: string): string { - return `/paperclip/instances/default/run-logs/${companyId}/${agentId}/${runId}.pod.ndjson`; + return `/paperclip/instances/default/data/run-logs/${companyId}/${agentId}/${runId}.pod.ndjson`; } /** Prompts above this size (bytes) are staged via a Secret instead of an @@ -504,7 +504,7 @@ export function buildJobManifest(input: JobBuildInput): JobBuildResult { name: "write-prompt", image: "busybox:1.36", imagePullPolicy: "IfNotPresent", - command: ["sh", "-c", `mkdir -p /paperclip/instances/default/run-logs/${agent.companyId}/${agent.id} && cp /tmp/prompt-secret/prompt.txt /tmp/prompt/prompt.txt`], + command: ["sh", "-c", "cp /tmp/prompt-secret/prompt.txt /tmp/prompt/prompt.txt"], volumeMounts: [ { name: "prompt", mountPath: "/tmp/prompt" }, { name: "prompt-secret", mountPath: "/tmp/prompt-secret", readOnly: true }, @@ -519,7 +519,7 @@ export function buildJobManifest(input: JobBuildInput): JobBuildResult { name: "write-prompt", image: "busybox:1.36", imagePullPolicy: "IfNotPresent", - command: ["sh", "-c", `mkdir -p /paperclip/instances/default/run-logs/${agent.companyId}/${agent.id} && printf '%s' "$PROMPT_CONTENT" > /tmp/prompt/prompt.txt`], + command: ["sh", "-c", `printf '%s' "$PROMPT_CONTENT" > /tmp/prompt/prompt.txt`], env: [{ name: "PROMPT_CONTENT", value: prompt }], volumeMounts: [{ name: "prompt", mountPath: "/tmp/prompt" }], securityContext,