diff --git a/src/resources/extensions/gsd/auto-start.ts b/src/resources/extensions/gsd/auto-start.ts index 5d10a54f8..5856bd0b9 100644 --- a/src/resources/extensions/gsd/auto-start.ts +++ b/src/resources/extensions/gsd/auto-start.ts @@ -678,7 +678,7 @@ export async function bootstrapAutoSession( } // ── DB lifecycle ── - const gsdDbPath = join(s.basePath, ".gsd", "gsd.db"); + const gsdDbPath = resolveProjectRootDbPath(s.basePath); const gsdDirPath = join(s.basePath, ".gsd"); if (existsSync(gsdDirPath) && !existsSync(gsdDbPath)) { const hasDecisions = existsSync(join(gsdDirPath, "DECISIONS.md")); diff --git a/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts b/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts new file mode 100644 index 000000000..f32bf41fb --- /dev/null +++ b/src/resources/extensions/gsd/tests/auto-start-worktree-db-path.test.ts @@ -0,0 +1,28 @@ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +import { createTestContext } from "./test-helpers.ts"; + +const { assertTrue, report } = createTestContext(); + +const srcPath = join(import.meta.dirname, "..", "auto-start.ts"); +const src = readFileSync(srcPath, "utf-8"); + +console.log("\n=== #3822: worktree bootstrap uses project DB path ==="); + +const dbLifecycleIdx = src.indexOf("// ── DB lifecycle ──"); +assertTrue(dbLifecycleIdx > 0, "auto-start.ts has a DB lifecycle section"); + +const dbLifecycleRegion = dbLifecycleIdx > 0 ? src.slice(dbLifecycleIdx, dbLifecycleIdx + 600) : ""; + +assertTrue( + dbLifecycleRegion.includes("const gsdDbPath = resolveProjectRootDbPath(s.basePath);"), + "DB lifecycle resolves the project-root DB path after worktree entry (#3822)", +); + +assertTrue( + !dbLifecycleRegion.includes('join(s.basePath, ".gsd", "gsd.db")'), + "DB lifecycle no longer derives gsd.db directly from the worktree path (#3822)", +); + +report();