feat(deletions): add pruning and git history fallback
Implements two P1 tasks for the deletions manifest epic: bd-v2x: Add deletions pruning to bd compact - PruneDeletions function removes records older than retention period - Default retention: 7 days (configurable via metadata.json) - CLI --retention flag for override - Atomic file rewrite prevents corruption - Called automatically during all compact operations bd-pnm: Add git history fallback for pruned deletions - Catches deletions where manifest entry was pruned - Uses git log -S to search for ID in JSONL history - Batches multiple IDs for efficiency (git -G regex) - Self-healing: backfills manifest on hit - Conservative: keeps issue if git check fails (shallow clone) Tests added for both features with edge cases covered. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1067,3 +1067,43 @@ func TestConcurrentExternalRefImports(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestCheckGitHistoryForDeletions_EmptyList(t *testing.T) {
|
||||
// Empty list should return nil
|
||||
result := checkGitHistoryForDeletions("/tmp/test", nil)
|
||||
if result != nil {
|
||||
t.Errorf("Expected nil for empty list, got %v", result)
|
||||
}
|
||||
|
||||
result = checkGitHistoryForDeletions("/tmp/test", []string{})
|
||||
if result != nil {
|
||||
t.Errorf("Expected nil for empty slice, got %v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckGitHistoryForDeletions_NonGitDir(t *testing.T) {
|
||||
// Non-git directory should return empty (conservative behavior)
|
||||
tmpDir := t.TempDir()
|
||||
result := checkGitHistoryForDeletions(tmpDir, []string{"bd-test"})
|
||||
if len(result) != 0 {
|
||||
t.Errorf("Expected empty result for non-git dir, got %v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWasInGitHistory_NonGitDir(t *testing.T) {
|
||||
// Non-git directory should return false (conservative behavior)
|
||||
tmpDir := t.TempDir()
|
||||
result := wasInGitHistory(tmpDir, ".beads/beads.jsonl", "bd-test")
|
||||
if result {
|
||||
t.Error("Expected false for non-git dir")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchCheckGitHistory_NonGitDir(t *testing.T) {
|
||||
// Non-git directory should return empty (falls back to individual checks)
|
||||
tmpDir := t.TempDir()
|
||||
result := batchCheckGitHistory(tmpDir, ".beads/beads.jsonl", []string{"bd-test1", "bd-test2"})
|
||||
if len(result) != 0 {
|
||||
t.Errorf("Expected empty result for non-git dir, got %v", result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user