fix(init): use server-aware diagnostics (#4954)

Route init-time database checks through one shared store so server-mode projects do not require a local .beads/dolt directory. Add a server-backed regression for the successful no-local-directory case.

Agent-Signature: codex-gpt-5.6-sol-high on behalf of matt wilkie
This commit is contained in:
matt wilkie 2026-07-22 21:20:10 -07:00 • committed by GitHub
commit ce728d04ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 3 deletions

View file

@ -996,22 +996,28 @@ func runInitDiagnostics(path string) doctorResult {
result.OverallOK = false
}
// Open one shared store for the database-backed init checks. Server-mode
// workspaces may not have a local .beads/dolt directory, so the path-only
// checks would otherwise report a false missing database.
sharedStore := doctor.NewSharedStore(path)
defer sharedStore.Close()
// Check 2: Database version
dbCheck := convertWithCategory(doctor.CheckDatabaseVersion(path, Version), doctor.CategoryCore)
dbCheck := convertWithCategory(doctor.CheckDatabaseVersionWithStore(sharedStore, Version), doctor.CategoryCore)
result.Checks = append(result.Checks, dbCheck)
if dbCheck.Status == statusError {
result.OverallOK = false
}
// Check 3: Schema compatibility
schemaCheck := convertWithCategory(doctor.CheckSchemaCompatibility(path), doctor.CategoryCore)
schemaCheck := convertWithCategory(doctor.CheckSchemaCompatibilityWithStore(sharedStore), doctor.CategoryCore)
result.Checks = append(result.Checks, schemaCheck)
if schemaCheck.Status == statusError {
result.OverallOK = false
}
// Check 4: Permissions
permCheck := convertWithCategory(doctor.CheckPermissions(path), doctor.CategoryCore)
permCheck := convertWithCategory(doctor.CheckPermissionsWithStore(path, sharedStore), doctor.CategoryCore)
result.Checks = append(result.Checks, permCheck)
if permCheck.Status == statusError {
result.OverallOK = false

View file

@ -0,0 +1,32 @@
//go:build cgo
package main
import (
"os"
"path/filepath"
"testing"
)
func TestRunInitDiagnosticsServerModeWithoutLocalDoltDir(t *testing.T) {
projectDir := t.TempDir()
doltPath := filepath.Join(projectDir, ".beads", "dolt")
store := newTestStoreIsolatedDB(t, doltPath, "initdiag")
if err := store.Close(); err != nil {
t.Fatalf("close setup store: %v", err)
}
if info, err := os.Stat(doltPath); err == nil || !os.IsNotExist(err) {
t.Fatalf("expected no local .beads/dolt directory, got info=%v err=%v", info, err)
}
result := runInitDiagnostics(projectDir)
for _, check := range result.Checks {
if check.Message == "No dolt database found" {
t.Fatalf("runInitDiagnostics reported false missing database: %+v", check)
}
}
if !result.OverallOK {
t.Fatalf("runInitDiagnostics OverallOK=false: %+v", result.Checks)
}
}