fix(federation): allow daemon mode with --federation flag for dolt
Update guards to allow daemon commands when --federation is set. Federation mode runs dolt sql-server which enables multi-writer support, unlike embedded Dolt which is single-process only. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
da4584ae57
commit
8807a171d3
@@ -26,6 +26,8 @@ func singleProcessBackendHelp(backend string) string {
|
||||
// daemon architecture relies on multiple processes (CLI + daemon + helper spawns),
|
||||
// which can trigger lock contention and transient "read-only" failures.
|
||||
//
|
||||
// Exception: --federation flag enables dolt sql-server mode which is multi-writer.
|
||||
//
|
||||
// We still allow help output so users can discover the command surface.
|
||||
func guardDaemonUnsupportedForDolt(cmd *cobra.Command, _ []string) error {
|
||||
// Allow `--help` for any daemon subcommand.
|
||||
@@ -35,6 +37,13 @@ func guardDaemonUnsupportedForDolt(cmd *cobra.Command, _ []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow `--federation` flag which enables dolt sql-server (multi-writer) mode.
|
||||
if fedFlag := cmd.Flags().Lookup("federation"); fedFlag != nil {
|
||||
if federation, _ := cmd.Flags().GetBool("federation"); federation {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Best-effort determine the active workspace backend. If we can't determine it,
|
||||
// don't block (the command will likely fail later anyway).
|
||||
beadsDir := beads.FindBeadsDir()
|
||||
|
||||
@@ -376,10 +376,11 @@ func startDaemon(interval time.Duration, autoCommit, autoPush, autoPull, localMo
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Guardrail: single-process backends (e.g., Dolt) must never spawn a daemon process.
|
||||
// Guardrail: single-process backends (e.g., Dolt embedded) must never spawn a daemon process.
|
||||
// Exception: federation mode runs dolt sql-server which enables multi-writer support.
|
||||
// This should already be blocked by command guards, but keep it defensive.
|
||||
if singleProcessOnlyBackend() {
|
||||
fmt.Fprintf(os.Stderr, "Error: daemon mode is not supported for single-process backends (e.g., dolt). Hint: use sqlite backend for daemon mode, or run commands in direct mode\n")
|
||||
if singleProcessOnlyBackend() && !federation {
|
||||
fmt.Fprintf(os.Stderr, "Error: daemon mode is not supported for single-process backends (e.g., dolt). Hint: use sqlite backend for daemon mode, use --federation for dolt server mode, or run commands in direct mode\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestDoltSingleProcess_StartDaemonGuardrailExitsNonZero(t *testing.T) {
|
||||
dbPath = ""
|
||||
|
||||
pidFile := filepath.Join(ws, ".beads", "daemon.pid")
|
||||
startDaemon(5*time.Second, false, false, false, false, false, "", pidFile, "info", false)
|
||||
startDaemon(5*time.Second, false, false, false, false, false, "", pidFile, "info", false, false)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user