fix: add --allow-stale to --no-daemon reads for resilience (#465)

The beads.go run() function uses --no-daemon for faster read operations,
but this fails when the database is out of sync with JSONL (e.g., after
the daemon is killed during shutdown before it can sync).

Adding --allow-stale prevents these failures and makes witness/refinery
startup more reliable after gt down --all.
This commit is contained in:
dustin
2026-01-14 04:18:07 +07:00
committed by GitHub
parent 8051c8bdd7
commit 503e66ba8d
+4 -2
View File
@@ -129,8 +129,10 @@ func NewWithBeadsDir(workDir, beadsDir string) *Beads {
// run executes a bd command and returns stdout.
func (b *Beads) run(args ...string) ([]byte, error) {
// Use --no-daemon for faster read operations (avoids daemon IPC overhead)
// The daemon is primarily useful for write coalescing, not reads
fullArgs := append([]string{"--no-daemon"}, args...)
// The daemon is primarily useful for write coalescing, not reads.
// Use --allow-stale to prevent failures when db is out of sync with JSONL
// (e.g., after daemon is killed during shutdown before syncing).
fullArgs := append([]string{"--no-daemon", "--allow-stale"}, args...)
cmd := exec.Command("bd", fullArgs...) //nolint:gosec // G204: bd is a trusted internal tool
cmd.Dir = b.workDir