{"record":{"id":"16dd55ea0614d8c1","repo":"paperclipai/paperclip","slug":"worktree-seed-manifest-source-instance-does-not-ma","errorCode":null,"errorMessage":"Worktree seed manifest source instance does not match the registered source instance.","messagePattern":"Worktree seed manifest source instance does not match the registered source instance\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/src/worktree-seed-source.ts","lineNumber":221,"sourceCode":"  manifestSource: WorktreeSeedSourceDiagnostic | null | undefined;\n  manifestTargetInstanceId?: unknown;\n}): CanonicalWorktreeSeedSource {\n  const registered = resolveRegisteredWorktreeSeedSource(input);\n  const diagnosticPath = typeof input.manifestSource?.configPath === \"string\"\n    ? input.manifestSource.configPath.trim()\n    : \"\";\n  if (!diagnosticPath) {\n    throw new Error(\"Worktree seed manifest is missing source path diagnostics.\");\n  }\n  const canonicalDiagnosticPath = canonicalRegularFile(\n    diagnosticPath,\n    \"Worktree seed manifest source diagnostic\",\n  );\n  if (path.resolve(diagnosticPath) !== registered.configPath || canonicalDiagnosticPath !== registered.configPath) {\n    throw new Error(\"Worktree seed manifest source path does not match the registered canonical source.\");\n  }\n  if (input.manifestSource?.instanceId !== registered.instanceId) {\n    throw new Error(\"Worktree seed manifest source instance does not match the registered source instance.\");\n  }\n  if (input.manifestTargetInstanceId !== registered.targetInstanceId) {\n    throw new Error(\"Worktree seed manifest target instance does not match the registered target instance.\");\n  }\n  return registered;\n}\n","sourceCodeStart":203,"sourceCodeEnd":228,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/packages/shared/src/worktree-seed-source.ts#L203-L228","documentation":"The manifest's source.instanceId is compared against the instance id resolved from the registered source config's adjacent .env (or instances/<id> root). A mismatch means the manifest was written against a different source instance than the one the registration currently points at, so its diagnostics no longer describe reality.","triggerScenarios":"manifestSource.instanceId (missing, hence undefined, or a stale value) vs registered.instanceId from readInstanceId() — e.g. the base workspace's instance was recreated or the manifest was copied from another instance's worktree.","commonSituations":"Instance reset (`rm -rf` of instance data and re-init) issuing a new id while old manifests remain; manifests copied between worktrees of different instances; partial manifest updates; fixture reuse in tests.","solutions":["Read the current source instance id: `grep PAPERCLIP_INSTANCE_ID <source-config-dir>/.env`.","Update the manifest's `source.instanceId` to that value (or regenerate the manifest).","Clean out stale manifests whenever the base instance is recreated."],"exampleFix":"# before: manifest names the pre-reset instance\n\"source\": { \"configPath\": \"...\", \"instanceId\": \"old-id\" }\n\n# after\n\"source\": { \"configPath\": \"...\", \"instanceId\": \"$(grep -oP '(?<=PAPERCLIP_INSTANCE_ID=).*' <source>/.paperclip/.env)\" }","handlingStrategy":"validation","validationCode":"const currentSourceId = instanceIdFromEnv(sourceConfigPath); // reads adjacent .env\nif (manifest.source.instanceId !== currentSourceId) {\n  throw new Error(\"manifest source instance id is stale — regenerate the manifest\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate manifests whenever the base instance is recreated.","Derive manifest ids from the live configs at write time, never from cached values.","Add a doctor command that compares manifest ids against current .env ids."],"tags":["manifest","instance-id","worktree-seed","stale-state"],"backgroundTag":"instance-id-mismatch","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","contentChangedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}