Merge pull request #452 from julianknutsen/fix/close-delete-hard-bug-workaround

fix(beads): use close instead of delete for agent bead lifecycle
This commit is contained in:
Steve Yegge
2026-01-13 13:32:56 -08:00
committed by GitHub
3 changed files with 677 additions and 8 deletions

View File

@@ -446,12 +446,14 @@ func (m *Manager) RemoveWithOptions(name string, force, nuclear bool) error {
m.namePool.Release(name)
_ = m.namePool.Save()
// Delete agent bead (non-fatal: may not exist or beads may not be available)
// Close agent bead (non-fatal: may not exist or beads may not be available)
// NOTE: We use CloseAndClearAgentBead instead of DeleteAgentBead because bd delete --hard
// creates tombstones that cannot be reopened.
agentID := m.agentBeadID(name)
if err := m.beads.DeleteAgentBead(agentID); err != nil {
if err := m.beads.CloseAndClearAgentBead(agentID, "polecat removed"); err != nil {
// Only log if not "not found" - it's ok if it doesn't exist
if !errors.Is(err, beads.ErrNotFound) {
fmt.Printf("Warning: could not delete agent bead %s: %v\n", agentID, err)
fmt.Printf("Warning: could not close agent bead %s: %v\n", agentID, err)
}
}
@@ -529,11 +531,13 @@ func (m *Manager) RepairWorktreeWithOptions(name string, force bool, opts AddOpt
}
}
// Delete old agent bead before recreation (non-fatal)
// Close old agent bead before recreation (non-fatal)
// NOTE: We use CloseAndClearAgentBead instead of DeleteAgentBead because bd delete --hard
// creates tombstones that cannot be reopened.
agentID := m.agentBeadID(name)
if err := m.beads.DeleteAgentBead(agentID); err != nil {
if err := m.beads.CloseAndClearAgentBead(agentID, "polecat repair"); err != nil {
if !errors.Is(err, beads.ErrNotFound) {
fmt.Printf("Warning: could not delete old agent bead %s: %v\n", agentID, err)
fmt.Printf("Warning: could not close old agent bead %s: %v\n", agentID, err)
}
}