fix(daemon): allow read-only daemon commands with Dolt backend

The daemon guard was blocking ALL daemon commands when using Dolt
backend, including read-only commands like `status`, `stop`, `logs`.

Changes:
- Rename guard to `guardDaemonStartForDolt` (more accurate)
- Remove `PersistentPreRunE` from `daemonCmd` and `daemonsCmd`
- Add `PreRunE` guard only to `daemonStartCmd` and `daemonsRestartCmd`
- Update test to use new function name and test start command

Now:
- `bd daemon status` works with Dolt backend
- `bd daemon start` blocked unless `--federation` flag
- `bd daemon start --federation` works (starts dolt sql-server)

Fixes: bd-n7o47

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/emma
2026-01-21 18:05:53 -08:00
committed by Steve Yegge
parent 4e3e9d1441
commit bb4549abdd
5 changed files with 17 additions and 11 deletions

View File

@@ -69,7 +69,7 @@ func TestDoltSingleProcess_TryAutoStartDoesNotCreateStartlock(t *testing.T) {
}
}
func TestDoltSingleProcess_DaemonGuardBlocksCommands(t *testing.T) {
func TestDoltSingleProcess_DaemonGuardBlocksStartCommand(t *testing.T) {
oldDBPath := dbPath
t.Cleanup(func() { dbPath = oldDBPath })
dbPath = ""
@@ -78,12 +78,14 @@ func TestDoltSingleProcess_DaemonGuardBlocksCommands(t *testing.T) {
beadsDir, _ := writeDoltWorkspace(t, ws)
t.Setenv("BEADS_DIR", beadsDir)
// Ensure help flag exists (cobra adds it during execution; for unit testing we add it explicitly).
cmd := daemonCmd
// Use daemonStartCmd which has the guard attached.
// Ensure help and federation flags exist (cobra adds them during execution).
cmd := daemonStartCmd
cmd.Flags().Bool("help", false, "help")
err := guardDaemonUnsupportedForDolt(cmd, nil)
// Note: federation flag is already registered in init()
err := guardDaemonStartForDolt(cmd, nil)
if err == nil {
t.Fatalf("expected daemon guard error for dolt backend")
t.Fatalf("expected daemon guard error for dolt backend without --federation")
}
if !strings.Contains(err.Error(), "single-process") {
t.Fatalf("expected error to mention single-process, got: %v", err)