fix(gsd): open DB on demand in gsd_milestone_status for non-auto sessions

gsd_milestone_status checked isDbAvailable() but never called
ensureDbOpen(), making it always fail outside auto-mode sessions where
the DB is pre-opened during bootstrap.

Replace with ensureDbOpen() which safely opens existing DB files without
side effects when .gsd/ content exists.

Closes #3644

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tibsfox 2026-04-06 18:49:50 -07:00
parent b4c6229360
commit 745865f1c6

View file

@ -22,17 +22,18 @@ export function registerQueryTools(pi: ExtensionAPI): void {
}),
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
try {
// Strictly read-only: only use an already-open DB connection.
// Do NOT call ensureDbOpen() — it can create/migrate the DB as a side effect.
// Open the DB if not already open — safe for read-only use since
// ensureDbOpen() only creates/migrates when .gsd/ has content (#3644).
const { ensureDbOpen } = await import("./dynamic-tools.js");
const dbAvailable = await ensureDbOpen();
const {
isDbAvailable,
getMilestone,
getSliceStatusSummary,
getSliceTaskCounts,
_getAdapter,
} = await import("../gsd-db.js");
if (!isDbAvailable()) {
if (!dbAvailable) {
return {
content: [{ type: "text" as const, text: "Error: GSD database is not available." }],
details: { operation: "milestone_status", error: "db_unavailable" } as any,