{"record":{"id":"50f313673164eced","repo":"paperclipai/paperclip","slug":"source-and-target-paperclip-configs-are-the-same-c","errorCode":null,"errorMessage":"Source and target Paperclip configs are the same canonical file.","messagePattern":"Source and target Paperclip configs are the same canonical file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/src/worktree-seed-source.ts","lineNumber":171,"sourceCode":"  }\n  const canonicalSourceConfigPath = canonicalRegularFile(selectedPath, \"Registered source Paperclip config\");\n  if (registeredConfigPath && canonicalSourceConfigPath !== registeredConfigPath) {\n    throw new Error(\"Registered source Paperclip config escapes the base project workspace or uses a symlink alias.\");\n  }\n\n  if (explicitSource) {\n    const canonicalExplicitSource = canonicalRegularFile(explicitSource, \"Explicit source Paperclip config\");\n    if (canonicalExplicitSource !== canonicalSourceConfigPath) {\n      throw new Error(\"Explicit source Paperclip config does not match the registered base project workspace.\");\n    }\n  }\n\n  const canonicalTargetConfigPath = canonicalRegularFile(\n    input.targetConfigPath,\n    \"Target worktree Paperclip config\",\n  );\n  if (canonicalSourceConfigPath === canonicalTargetConfigPath) {\n    throw new Error(\"Source and target Paperclip configs are the same canonical file.\");\n  }\n\n  const sourceInstanceId = readInstanceId(canonicalSourceConfigPath, \"source\");\n  const targetInstanceId = readInstanceId(canonicalTargetConfigPath, \"target\");\n  if (targetInstanceId !== input.expectedTargetInstanceId) {\n    throw new Error(\"Target Paperclip instance does not match the registered worktree instance.\");\n  }\n  if (sourceInstanceId === targetInstanceId) {\n    throw new Error(\"Source and target Paperclip configs name the same instance.\");\n  }\n\n  return {\n    baseWorkspaceCwd: canonicalBaseCwd,\n    configPath: canonicalSourceConfigPath,\n    instanceId: sourceInstanceId,\n    targetConfigPath: canonicalTargetConfigPath,\n    targetInstanceId,\n  };","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/packages/shared/src/worktree-seed-source.ts#L153-L189","documentation":"resolveRegisteredWorktreeSeedSource canonicalizes both the source config and the target worktree config and found them identical: the seed operation's destination is the same file as its source. Seeding would overwrite its own origin, so the invariant check rejects it.","triggerScenarios":"Running worktree seed from inside the base workspace with the target worktree path resolving to the base itself; passing --from-config equal to the target worktree's config; a target cwd that symlinks back to the base (both canonicalize to one path).","commonSituations":"Invoking the seed command in the wrong directory (base instead of the new worktree); CI scripts reusing `$PWD` for both source and target; misconfigured worktree root pointing at the checkout root.","solutions":["Run the command from the new worktree directory (or pass its path) so the target config is the worktree's own, not the base's.","Verify `realpath <target>/.paperclip/config.json` differs from the source config.","If --from-config was meant to seed this worktree, make sure the worktree's own config.json path is the target, not the source file."],"exampleFix":"# before (run inside the base workspace)\npaperclip worktree seed --from-config ./.paperclip/config.json   # target == source\n\n# after (run inside the new worktree)\ncd ../worktrees/issue-42 && paperclip worktree seed --from-config \"$(realpath ../../base/.paperclip/config.json)\"","handlingStrategy":"validation","validationCode":"import { realpathSync } from \"node:fs\";\n\nconst src = realpathSync(sourceConfigPath);\nconst dst = realpathSync(targetConfigPath);\nif (src === dst) throw new Error(\"refusing to seed a worktree onto itself\");","typeGuard":"const isDistinctTarget = (src: string, dst: string): boolean => {\n  try { return realpathSync(src) !== realpathSync(dst); } catch { return false; }\n};","tryCatchPattern":null,"preventionTips":["Always run seed commands from the new worktree, never the base workspace.","Assert `process.cwd() !== baseWorkspaceCwd` in seed wrappers.","Guard CI scripts that interpolate `$PWD` into both source and target."],"tags":["worktree-seed","config","self-reference"],"backgroundTag":"same-source-and-target","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","contentChangedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}