Complete bd-175, bd-176, bd-177: Memory tests, corruption docs, prefix validation

- bd-175: Added comprehensive test coverage for internal/storage/memory backend
  - All CRUD operations, dependencies, labels, comments
  - Thread safety with race detection
  - LoadFromIssues and counter sync
  - Fixed batch duplicate detection

- bd-176: Documented corruption vs collision distinction
  - Added FAQ entry explaining logical vs physical corruption
  - Updated TROUBLESHOOTING with clear guidance
  - Clarified when to use collision resolution vs reimport

- bd-177: Added prefix validation in SQLite mode
  - Validates explicit IDs match configured prefix
  - Works in both CreateIssue and CreateIssues
  - Comprehensive tests for single and batch operations
This commit is contained in:
Steve Yegge
2025-10-27 11:29:08 -07:00
parent f5e1a9811a
commit 68ffb9ed40
6 changed files with 1171 additions and 27 deletions

View File

@@ -209,6 +209,9 @@ func (m *MemoryStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
prefix = "bd"
}
// Track IDs in this batch to detect duplicates within batch
batchIDs := make(map[string]bool)
// Generate IDs for issues that need them
for _, issue := range issues {
issue.CreatedAt = now
@@ -219,10 +222,16 @@ func (m *MemoryStorage) CreateIssues(ctx context.Context, issues []*types.Issue,
issue.ID = fmt.Sprintf("%s-%d", prefix, m.counters[prefix])
}
// Check for duplicates
// Check for duplicates in existing issues
if _, exists := m.issues[issue.ID]; exists {
return fmt.Errorf("issue %s already exists", issue.ID)
}
// Check for duplicates within this batch
if batchIDs[issue.ID] {
return fmt.Errorf("duplicate ID within batch: %s", issue.ID)
}
batchIDs[issue.ID] = true
}
// Store all issues