fix(dolt): server mode should support multi-process access

Code review fix: In server mode, Dolt connects to an external sql-server
and should NOT be single-process-only. The whole point of server mode is
to enable multi-writer access.

Changes:
- Add Config.GetCapabilities() method that considers server mode
- Update daemon_guard, daemon_autostart, daemons, main to use GetCapabilities()
- Add TestGetCapabilities test
- Update init command help text to document server mode flags

The existing CapabilitiesForBackend(string) is kept for backward compatibility
but now includes a note to use Config.GetCapabilities() when the full config
is available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
emma
2026-01-23 20:20:59 -08:00
committed by Steve Yegge
parent 484cd9d5fd
commit 433115725b
7 changed files with 74 additions and 9 deletions

View File

@@ -176,17 +176,35 @@ type BackendCapabilities struct {
// CapabilitiesForBackend returns capabilities for a backend string.
// Unknown backends are treated conservatively as single-process-only.
//
// Note: For Dolt, this returns SingleProcessOnly=true for embedded mode.
// Use Config.GetCapabilities() when you have the full config to properly
// handle server mode (which supports multi-process access).
func CapabilitiesForBackend(backend string) BackendCapabilities {
switch strings.TrimSpace(strings.ToLower(backend)) {
case "", BackendSQLite:
return BackendCapabilities{SingleProcessOnly: false}
case BackendDolt:
// Embedded Dolt is single-process-only.
// Server mode is handled by Config.GetCapabilities().
return BackendCapabilities{SingleProcessOnly: true}
default:
return BackendCapabilities{SingleProcessOnly: true}
}
}
// GetCapabilities returns the backend capabilities for this config.
// Unlike CapabilitiesForBackend(string), this considers Dolt server mode
// which supports multi-process access.
func (c *Config) GetCapabilities() BackendCapabilities {
backend := c.GetBackend()
if backend == BackendDolt && c.IsDoltServerMode() {
// Server mode supports multi-writer, so NOT single-process-only
return BackendCapabilities{SingleProcessOnly: false}
}
return CapabilitiesForBackend(backend)
}
// GetBackend returns the configured backend type, defaulting to SQLite.
func (c *Config) GetBackend() string {
if c.Backend == "" {