{"record":{"id":"7e12909216dbb2ee","repo":"thedotmack/claude-mem","slug":"worktree-adoption-skipped-branch","errorCode":null,"errorMessage":"Worktree adoption skipped branch","messagePattern":"Worktree adoption skipped branch","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/infrastructure/WorktreeAdoption.ts","lineNumber":283,"sourceCode":"        sumChanges = updateSum.run(parentProject, worktreeProject).changes;\n      }\n      for (const r of rows) {\n        adoptedChromaTargets.push({ docType: 'observation', sqliteId: r.id });\n      }\n      for (const r of summaryRows) {\n        adoptedChromaTargets.push({ docType: 'session_summary', sqliteId: r.id });\n      }\n      result.adoptedObservations += obsChanges;\n      result.adoptedSummaries += sumChanges;\n    };\n\n    const tx = db.transaction(() => {\n      for (const wt of targets) {\n        try {\n          adoptWorktreeInTransaction(wt);\n        } catch (err) {\n          const message = err instanceof Error ? err.message : String(err);\n          logger.warn('SYSTEM', 'Worktree adoption skipped branch', {\n            worktree: wt.path,\n            branch: wt.branch,\n            error: message\n          });\n          result.errors.push({ worktree: wt.path, error: message });\n        }\n      }\n      if (dryRun) {\n        throw new DryRunRollback();\n      }\n    });\n\n    try {\n      tx();\n    } catch (err) {\n      if (err instanceof DryRunRollback) {\n        // Rolled back as intended for dry-run — counts are still useful.\n      } else if (err instanceof Error) {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/infrastructure/WorktreeAdoption.ts#L265-L301","documentation":"Worktree adoption wraps per-worktree adoption in one SQLite transaction, with each branch adopted inside its own try/catch via adoptWorktreeInTransaction. When a single worktree fails (bad metadata, constraint violation, or statements failing because the shared transaction already aborted), this warning records the worktree path and error into result.errors and continues. Under dryRun, all changes still roll back by design via DryRunRollback.","triggerScenarios":"Inside the transaction, adopting one worktree throws: unexpected row shape in the worktree's data, UNIQUE constraint on re-adoption of already-adopted rows, or SQLite errors cascading after an earlier statement poisoned the transaction.","commonSituations":"Re-running adoption over partially adopted data; worktrees with unusual branch names or detached HEAD; a concurrent writer aborting the shared transaction so every subsequent statement fails.","solutions":["Read result.errors — each entry pairs the failing worktree path with the underlying message; fix the first entry's cause first.","Re-run adoption: per-branch failures are non-fatal and idempotent re-runs usually clear transient ones.","If every branch fails with transaction-level errors, one early failure poisoned the transaction — resolve that branch or exclude it.","Remember dry runs roll back everything by design; only non-dry runs persist adoptions."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// dry-run first: surface per-branch errors without writing anything\nconst dry = await adoptMergedWorktrees({ repoPath, dataDirectory, dryRun: true });\nif (dry.errors.length > 0) {\n  reportAndFix(dry.errors); // address the first entry before the real run\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always dry-run adoption before the mutating run and read result.errors.","Re-run adoption after fixing one branch — failures are per-branch and idempotent.","Avoid running adoption while another writer holds the DB."],"tags":["git-worktree","sqlite","transaction","adoption"],"backgroundTag":"sqlite-transaction-failed","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}