Skip to content

bd sync silently wipes local beads when branch not pushed to remote #314

@vnnkl

Description

@vnnkl

Summary

When using bd sync (or the beads tracker in ralph-tui), if the current git branch hasn't been pushed to the remote yet, bd sync's git pull fails and silently overwrites the local JSONL with the main branch version — destroying all locally-created beads.

Steps to Reproduce

  1. Create a new local branch: git checkout -b my-feature
  2. Do NOT push to remote
  3. Create beads: bd create --type=epic --title="My Feature" ... + child beads
  4. Verify beads exist: bd list shows them
  5. Run ralph-tui run --tracker beads --epic <id> (or bd sync)
  6. Beads are gone — bd list no longer shows them

Expected Behavior

  • If git pull fails (branch not on remote), local state should be preserved
  • bd sync should not silently destroy local beads on pull failure
  • At minimum, a warning/error should surface before any destructive operation

Actual Behavior

  • bd sync attempts git pull → fails (fatal: couldn't find remote ref <branch>)
  • JSONL gets reset to the main branch version (which doesn't have the new beads)
  • DB reimports from the (now empty) JSONL
  • All locally-created beads are silently lost
  • No error surfaced to the user

Additional Context

  • bd version: 0.47.1 (279192c5)
  • ralph-tui version: 0.7.1
  • The bd daemon also triggers this via its auto-sync cycle, making beads disappear even between manual bd list calls
  • Sync state shows the failure: "failure_reason": "git pull failed: exit status 1\nfatal: couldn't find remote ref add-email-signup\n"
  • Workaround: push branch to remote before creating beads, or use --no-daemon and avoid bd sync

Suggested Fix

When git pull fails, bd sync should:

  1. Not modify the local JSONL — preserve whatever was there before the sync attempt
  2. Log a clear warning: "Git pull failed — local state preserved, push branch to enable sync"
  3. Optionally: skip the pull step entirely when the branch has no upstream tracking ref

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions