{"record":{"id":"06b462b4ca7d9a3f","repo":"paperclipai/paperclip","slug":"worktree-seed-manifest-target-instance-does-not-ma","errorCode":null,"errorMessage":"Worktree seed manifest target instance does not match the registered target instance.","messagePattern":"Worktree seed manifest target instance does not match the registered target instance\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2314,"sourceCode":"    ?? nonEmpty(process.env.PAPERCLIP_COMPANY_ID)\n    ?? undefined;\n  if (!explicitSourceConfigPath && registeredBaseWorkspaceCwd && (!registeredProjectWorkspaceId || !expectedCompanyId)) {\n    throw new Error(\n      \"Managed worktree seed registration is incomplete; project workspace and company bindings are required.\",\n    );\n  }\n\n  const targetRoot = path.dirname(path.dirname(configPath));\n  const targetPaths = resolveWorktreeReseedTargetPaths({ configPath, rootPath: targetRoot });\n  const registeredSeedSource = resolveRegisteredWorktreeSeedSource({\n    registeredBaseWorkspaceCwd,\n    explicitSourceConfigPath,\n    targetConfigPath: configPath,\n    expectedTargetInstanceId: targetPaths.instanceId,\n  });\n\n  if (initialManifest && initialManifest.targetInstanceId !== registeredSeedSource.targetInstanceId) {\n    throw new Error(\"Worktree seed manifest target instance does not match the registered target instance.\");\n  }\n\n  // Resolve all authority-bearing paths before creating the lock. The manifest is\n  // agent-writable diagnostic evidence and never selects the source. A stale source\n  // diagnostic is replaced under the lock from this server/operator registration.\n  let canonicalSource = registeredSeedSource;\n  mkdirSync(path.dirname(markers.lock), { recursive: true });\n  const releaseLock = await acquireWorktreeSeedLock(markers.lock);\n  try {\n    // These checks deliberately happen under the cross-process lock. A second\n    // service process waits for the first seed transaction, then observes the\n    // verified manifest instead of cloning the same database concurrently.\n    let manifest = readWorktreeSeedManifest(configPath);\n    if (manifest?.state === \"verified\") {\n      return { seeded: false, reason: \"verified_manifest\" };\n    }\n    if (!manifest && existsSync(markers.pending)) {\n      const currentLegacyPending = readLegacyWorktreeSeedPendingMarker(markers.pending);","sourceCodeStart":2296,"sourceCodeEnd":2332,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/cli/src/commands/worktree.ts#L2296-L2332","documentation":"Before seeding, ensureWorktreeSeeded resolves the registered target instance id from the target's paths (resolveWorktreeReseedTargetPaths) and compares it with the targetInstanceId stored in an existing seed manifest. A mismatch means the manifest on disk describes a different worktree instance than the one being seeded — stale markers copied from another worktree, or the worktree's identity changed underneath the markers. The manifest is diagnostic evidence only and never selects the source; identity mismatches abort.","triggerScenarios":"A pre-existing manifest whose targetInstanceId differs from the registered target — copying/moving a worktree dir (markers came along, instance id re-derived from new paths), a regenerated instance id, or markers restored from another worktree's backup.","commonSituations":"Copying a worktree directory to a new name/path; restoring marker files from a different worktree; instance id regeneration after re-registration.","solutions":["Remove the stale manifest (and lock) markers for this worktree and re-run the seed so fresh markers are written","Verify the worktree was not moved or copied with its markers; recreate the worktree properly if identity is ambiguous","Re-register the worktree so registration and markers agree on the target instance"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const { instanceId } = resolveWorktreeReseedTargetPaths({ configPath, rootPath: targetRoot });\nconst manifest = readWorktreeSeedManifest(configPath);\nif (manifest && manifest.targetInstanceId !== instanceId) {\n  // stale markers from another worktree: clear them before seeding\n  removeSeedMarkers(configPath);\n}","typeGuard":null,"tryCatchPattern":"Catch the mismatch, print both ids, remove the stale markers, and re-run the seed once.","preventionTips":["Never copy or move worktree directories together with their marker files","Recreate worktrees through the CLI instead of cloning their directories"],"tags":["worktree","seed","manifest","instance-id","registration"],"backgroundTag":"instance-id-mismatch","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}