{"record":{"id":"ab96bacf75e8221b","repo":"paperclipai/paperclip","slug":"refusing-to-record-worktree-instance-ownership-for","errorCode":null,"errorMessage":"Refusing to record worktree instance ownership for \"${configured.instanceRoot}\" because it is outside \"${managedInstancesDir}\".","messagePattern":"Refusing to record worktree instance ownership for \"(.+?)\" because it is outside \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/workspace-instance-cleanup.ts","lineNumber":259,"sourceCode":"    ),\n  );\n  return path.join(managedWorktreesDir, \"instances\");\n}\n\nexport async function readManagedWorktreeInstanceOwnership(\n  workspacePath: string,\n  worktreesDir?: string,\n): Promise<{ instanceRoot: string; instanceId: string } | null> {\n  const pointer = await readWorktreeInstancePointer(workspacePath);\n  if (!pointer) return null;\n  const configured = resolveConfiguredInstanceRoot(pointer);\n  if (\"warning\" in configured) {\n    if (!configured.warning) return null;\n    throw new Error(configured.warning);\n  }\n  const managedInstancesDir = resolveManagedInstancesDir(worktreesDir);\n  if (!isStrictChildPath(configured.instanceRoot, managedInstancesDir)) {\n    throw new Error(\n      `Refusing to record worktree instance ownership for \"${configured.instanceRoot}\" because it is outside \"${managedInstancesDir}\".`,\n    );\n  }\n  return configured;\n}\n\nexport async function cleanupWorktreeInstanceArtifacts(input: {\n  pointer: WorktreeInstancePointer;\n  workspaceId: string;\n  workspacePath: string;\n  expectedInstanceId: string;\n  expectedInstanceRoot: string | null;\n  recorder?: WorkspaceOperationRecorder | null;\n  worktreesDir?: string;\n  dependencies?: WorktreeInstanceCleanupDependencies;\n}): Promise<WorktreeInstanceCleanupResult> {\n  const configured = resolveConfiguredInstanceRoot(input.pointer, input.expectedInstanceId);\n  if (\"warning\" in configured && !configured.warning) return { status: \"not_configured\" };","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/services/workspace-instance-cleanup.ts#L241-L277","documentation":"The worktree instance pointer names an instance root outside the managed instances directory, so ownership recording is refused. This safety check prevents Paperclip from tracking (and later cleaning up) directories it does not manage.","triggerScenarios":"Thrown at server/src/services/workspace-instance-cleanup.ts:237 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The instance root lies outside the managed instances directory. Move the instance under the managed directory or fix the instanceRoot configuration."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}