From 503e66ba8da8aa08d63b8c06a638ed7568590268 Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 14 Jan 2026 04:18:07 +0700 Subject: [PATCH] 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. --- internal/beads/beads.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/beads/beads.go b/internal/beads/beads.go index 6553b84b..121a31f4 100644 --- a/internal/beads/beads.go +++ b/internal/beads/beads.go @@ -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