{"record":{"id":"868adc0fdd99a1c0","repo":"paperclipai/paperclip","slug":"source-and-target-paperclip-configs-name-the-same","errorCode":null,"errorMessage":"Source and target Paperclip configs name the same instance.","messagePattern":"Source and target Paperclip configs name the same instance\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/src/worktree-seed-source.ts","lineNumber":180,"sourceCode":"      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  };\n}\n\n/**\n * Resolve a worktree seed source without granting authority to the seed manifest.\n *\n * A managed caller supplies the project-workspace cwd from its server-owned row.\n * An operator may instead supply an explicit source config. A base workspace that\n * carries its own `.paperclip/config.json` stays authoritative, so an explicit path\n * must equal it; a base workspace that is a plain checkout has none, and the explicit","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/packages/shared/src/worktree-seed-source.ts#L162-L198","documentation":"Source and target configs are distinct files (checked just before), but the instance ids read from them are equal. Seeding exists to copy state from one instance into a different one; two configs naming the same instance would fold the worktree back onto its own instance, so the resolver rejects it.","triggerScenarios":"A target worktree config (and its adjacent .env) copied wholesale from the base workspace, so PAPERCLIP_INSTANCE_ID matches the source; instance-root configs whose instances/<id> directory names collide between source and target.","commonSituations":"Cloning a worktree or base directory including `.paperclip/` (cp -a, rsync without exclude); templates that ship a pre-baked .env; forgetting that the worktree must get a fresh instance id before seeding.","solutions":["Compare `PAPERCLIP_INSTANCE_ID` in `<source>/.env` and `<target>/.paperclip/.env` — they must differ.","Re-issue the target worktree's config/.env with its own new instance id (re-create the worktree via the managed flow rather than copying).","Add `.paperclip/` to copy/rsync excludes when duplicating workspaces."],"exampleFix":"# before\ncp -a base worktrees/issue-42   # copies .paperclip/.env with the same instance id\n\n# after\ncp -a --exclude=.paperclip base worktrees/issue-42   # then let paperclip issue the worktree's own config","handlingStrategy":"validation","validationCode":"const ids = new Set<string>();\nfor (const cfg of [sourceConfigPath, targetConfigPath]) {\n  const id = instanceIdFromEnv(cfg); // helper reading PAPERCLIP_INSTANCE_ID\n  if (id) {\n    if (ids.has(id)) throw new Error(\"source and target share one instance id\");\n    ids.add(id);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Exclude `.paperclip/` when copying or templating worktrees (`rsync --exclude .paperclip`).","Provision a fresh instance id for every new worktree before seeding.","Add a pre-seed assertion that source and target ids differ."],"tags":["worktree-seed","instance-id","env-file","config"],"backgroundTag":"instance-id-mismatch","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}