fix(build): add CGO build constraints for Dolt-dependent files

The dolthub/gozstd dependency requires CGO. Several files were importing
the dolt package without build constraints, causing CI failures when
building with CGO_ENABLED=0 for Linux, FreeBSD, and Android.

Changes:
- Add //go:build cgo to federation.go and doctor/federation.go
- Create dolt_server_cgo.go/nocgo.go to abstract dolt.Server usage
- Create federation_nocgo.go with stub command explaining CGO requirement
- Create doctor/federation_nocgo.go with stub health checks
- Update daemon.go to use the dolt server abstraction

Federation and Dolt-specific features are unavailable in non-CGO builds.
Users are directed to pre-built binaries from GitHub releases.

Fixes v0.49.0 CI failure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
emma
2026-01-22 00:01:37 -08:00
committed by Steve Yegge
parent 9381190462
commit f91bbf3a03
7 changed files with 225 additions and 13 deletions

View File

@@ -17,7 +17,6 @@ import (
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/daemon"
"github.com/steveyegge/beads/internal/rpc"
"github.com/steveyegge/beads/internal/storage/dolt"
"github.com/steveyegge/beads/internal/storage/factory"
"github.com/steveyegge/beads/internal/storage/sqlite"
"github.com/steveyegge/beads/internal/syncbranch"
@@ -421,13 +420,17 @@ func runDaemonLoop(interval time.Duration, autoCommit, autoPush, autoPull, local
}
// Start dolt sql-server if federation mode is enabled and backend is dolt
var doltServer *dolt.Server
var doltServer *DoltServerHandle
factoryOpts := factory.Options{}
if federation && backend != configfile.BackendDolt {
log.Warn("federation mode requires dolt backend, ignoring --federation flag")
federation = false
}
if federation && backend == configfile.BackendDolt {
if !DoltServerAvailable() {
log.Error("federation mode requires CGO; use pre-built binaries from GitHub releases")
return
}
log.Info("starting dolt sql-server for federation mode")
doltPath := filepath.Join(beadsDir, "dolt")
@@ -436,22 +439,16 @@ func runDaemonLoop(interval time.Duration, autoCommit, autoPush, autoPull, local
// Use provided ports or defaults
sqlPort := federationPort
if sqlPort == 0 {
sqlPort = dolt.DefaultSQLPort
sqlPort = DoltDefaultSQLPort
}
remotePort := remotesapiPort
if remotePort == 0 {
remotePort = dolt.DefaultRemotesAPIPort
remotePort = DoltDefaultRemotesAPIPort
}
doltServer = dolt.NewServer(dolt.ServerConfig{
DataDir: doltPath,
SQLPort: sqlPort,
RemotesAPIPort: remotePort,
Host: "127.0.0.1",
LogFile: serverLogFile,
})
if err := doltServer.Start(ctx); err != nil {
var err error
doltServer, err = StartDoltServer(ctx, doltPath, serverLogFile, sqlPort, remotePort)
if err != nil {
log.Error("failed to start dolt sql-server", "error", err)
return
}