* fix: prefer bootstrap for missing database recovery Executed-By: beads/crew/emma * fix: align doctor recovery guidance with bootstrap Executed-By: beads/crew/emma * fix: let bootstrap recover missing server databases Executed-By: beads/crew/emma * fix: bootstrap missing server databases safely Executed-By: beads/crew/emma * fix: fail closed on bootstrap server probe errors Executed-By: beads/crew/emma * fix: honor runtime server config in bootstrap Executed-By: beads/crew/emma * docs: soften bootstrap-first recovery wording Executed-By: beads/crew/emma * fix: report resolved bootstrap server port Executed-By: beads/crew/emma * fix: repair test failures from build tag mismatch and mode detection Three issues causing CI failures on macOS and Ubuntu: 1. detectBootstrapAction used isEmbeddedMode() (global state) to choose the database path, but tests set cfg.DoltMode without updating the global serverMode flag. Switch to cfg.GetDoltMode() so the detection logic respects the config object passed by the caller. 2. TestDetectBootstrapAction_NoneWhenDatabaseExists created a "dolt" directory but default (embedded) config looks for "embeddeddolt". Fix the test to create the correct directory. 3. embeddeddolt/slots.go and new_methods_test.go used //go:build embeddeddolt tag while all other files in the package use cgo, causing interface satisfaction failures. Also fix undefined isEmbeddedDolt reference (should be isEmbeddedMode()). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Executed-By: beads/crew/emma --------- Co-authored-by: mayor <thalia.geraghty@fiserv.com> Co-authored-by: beads/crew/emma <steve.yegge@gmail.com>
82 lines
2.9 KiB
Go
82 lines
2.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// isFreshCloneError checks if the error is due to a fresh clone scenario
|
|
// where the database exists but is missing required config (like issue_prefix).
|
|
// This happens when someone clones a repo with beads but needs to initialize.
|
|
func isFreshCloneError(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
errStr := err.Error()
|
|
// Check for the specific migration invariant error pattern
|
|
return strings.Contains(errStr, "post-migration validation failed") &&
|
|
strings.Contains(errStr, "required config key missing: issue_prefix")
|
|
}
|
|
|
|
// handleFreshCloneError displays a helpful message when a fresh clone is detected
|
|
// and returns true if the error was handled (so caller should exit).
|
|
// If not a fresh clone error, returns false and does nothing.
|
|
func handleFreshCloneError(err error) bool {
|
|
if !isFreshCloneError(err) {
|
|
return false
|
|
}
|
|
|
|
fmt.Fprintf(os.Stderr, "Error: Database not initialized\n\n")
|
|
fmt.Fprintf(os.Stderr, "This appears to be a fresh clone or an existing project whose database needs recovery.\n")
|
|
fmt.Fprintf(os.Stderr, "\nTo diagnose, run:\n")
|
|
fmt.Fprintf(os.Stderr, " bd doctor\n\n")
|
|
fmt.Fprintf(os.Stderr, "If this is an existing project or fresh clone, run: bd bootstrap\n")
|
|
fmt.Fprintf(os.Stderr, "To create a brand-new database from scratch: bd init --prefix <your-prefix>\n")
|
|
return true
|
|
}
|
|
|
|
// isWispOperation returns true if the command operates on ephemeral wisps.
|
|
// Wisp operations use direct store access (local-only).
|
|
// Detects:
|
|
// - mol wisp subcommands (create, list, gc, or direct proto invocation)
|
|
// - mol burn (only operates on wisps)
|
|
// - mol squash (condenses wisps to digests)
|
|
// - Commands with ephemeral issue IDs in args (bd-*-wisp-*, wisp-*, or legacy eph-*)
|
|
func isWispOperation(cmd *cobra.Command, args []string) bool {
|
|
cmdName := cmd.Name()
|
|
|
|
// Check command hierarchy for wisp subcommands
|
|
// bd mol wisp → parent is "mol", cmd is "wisp"
|
|
// bd mol wisp create → parent is "wisp", cmd is "create"
|
|
if cmd.Parent() != nil {
|
|
parentName := cmd.Parent().Name()
|
|
// Direct wisp command or subcommands under wisp
|
|
if parentName == "wisp" || cmdName == "wisp" {
|
|
return true
|
|
}
|
|
// mol burn and mol squash are wisp-only operations
|
|
if parentName == "mol" && (cmdName == "burn" || cmdName == "squash") {
|
|
return true
|
|
}
|
|
}
|
|
|
|
// Check for ephemeral issue IDs in arguments
|
|
// Ephemeral IDs have "wisp" segment: bd-wisp-xxx, gt-wisp-xxx, wisp-xxx
|
|
// Also detect legacy "eph" prefix for backwards compatibility
|
|
for _, arg := range args {
|
|
// Skip flags
|
|
if strings.HasPrefix(arg, "-") {
|
|
continue
|
|
}
|
|
// Check for ephemeral prefix patterns (wisp-* or legacy eph-*)
|
|
if strings.Contains(arg, "-wisp-") || strings.HasPrefix(arg, "wisp-") ||
|
|
strings.Contains(arg, "-eph-") || strings.HasPrefix(arg, "eph-") {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|