{"record":{"id":"1e7229728a167dd1","repo":"coleam00/Archon","slug":"checkout-cwd-matches-multiple-registered-codeba","errorCode":null,"errorMessage":"Checkout ${cwd} matches multiple registered codebases through Git directory ${checkoutIdentity.commonGitDir}: ${paths}. Register this exact checkout or remove the ambiguity.","messagePattern":"Checkout (.+?) matches multiple registered codebases through Git directory (.+?): (.+?)\\. Register this exact checkout or remove the ambiguity\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/services/codebase-checkout-resolver.ts","lineNumber":64,"sourceCode":"  }\n\n  const checkoutIdentity = await deps.getGitCheckoutIdentity(cwd);\n  const matches: Codebase[] = [];\n  for (const codebase of await deps.listCodebases()) {\n    if (codebase.kind === 'folder') continue;\n    try {\n      const registeredIdentity = await deps.getGitCheckoutIdentity(codebase.default_cwd);\n      if (resolve(registeredIdentity.commonGitDir) === resolve(checkoutIdentity.commonGitDir)) {\n        matches.push(codebase);\n      }\n    } catch {\n      // A stale registered path cannot own the live checkout identity.\n    }\n  }\n\n  if (matches.length > 1) {\n    const paths = matches.map(codebase => codebase.default_cwd).join(', ');\n    throw new Error(\n      `Checkout ${cwd} matches multiple registered codebases through Git directory ` +\n        `${checkoutIdentity.commonGitDir}: ${paths}. Register this exact checkout or remove the ambiguity.`\n    );\n  }\n  return matches[0] ?? null;\n}\n","sourceCodeStart":46,"sourceCodeEnd":71,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/services/codebase-checkout-resolver.ts#L46-L71","documentation":"findCodebaseForCheckoutResolver resolves a filesystem checkout to a registered codebase using the checkout's Git identity (common git dir). When more than one registered codebase claims the same live checkout identity, resolution is ambiguous and it throws instead of guessing. The message asks the operator to register the exact checkout or remove the duplicate registration.","triggerScenarios":"Two or more registered codebases have default_cwd paths that resolve to checkouts sharing the same commonGitDir (e.g. the main checkout and a linked worktree both registered as separate codebases), and a lookup by checkout path matches both.","commonSituations":"Registering both the primary repo clone and one of its git worktrees as independent codebases; registering a nested checkout that shares the same .git directory; re-registering a moved checkout under a new path without removing the old entry.","solutions":["Register the exact checkout path being resolved so an exact match wins over identity matching.","Remove or update the duplicate codebase registrations so only one claims that Git directory.","If the duplicates are worktrees, keep only the primary clone registered; worktrees get isolation through worktree resolution, not separate registration.","Re-point the stale default_cwd of one registration to a different checkout."],"exampleFix":"// before: two registrations\nregisterCodebase({ default_cwd: '/repo' });\nregisterCodebase({ default_cwd: '/repo/.worktrees/feat' }); // same commonGitDir\n// after: one registration; worktrees resolve through it\nunregisterCodebase('/repo/.worktrees/feat');\nregisterCodebase({ default_cwd: '/repo' });","handlingStrategy":"validation","validationCode":"// before lookup, de-duplicate registrations sharing one git dir\nconst seen = new Set();\nfor (const cb of await listCodebases()) {\n  const id = await gitCommonDir(cb.default_cwd);\n  if (seen.has(id)) console.warn(`duplicate registration for git dir ${id}: ${cb.default_cwd}`);\n  seen.add(id);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cb = await findCodebaseForCheckoutPath(cwd);\n} catch (e) {\n  if (e.message.includes('matches multiple registered codebases')) {\n    console.error('Remove duplicate registrations or register this exact checkout');\n  } else throw e;\n}","preventionTips":["Register the primary clone only; never register its worktrees as separate codebases.","Remove stale registrations when a checkout moves.","Prefer exact-path registration for checkouts you resolve often."],"tags":["codebase","git","ambiguity","registration"],"backgroundTag":"ambiguous-codebase-registration","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}