fix(orphans): honor --db flag for cross-repo orphan detection (#1200)

* fix(orphans): honor --db flag for cross-repo orphan detection

Problem:
- `bd orphans --db /path` ignored the --db flag entirely
- FindOrphanedIssues() hardcoded local .beads/ directory

Solution:
- Introduce IssueProvider interface for abstract issue lookup
- Add StorageProvider adapter wrapping Storage instances
- Update FindOrphanedIssues to accept provider instead of path
- Wire orphans command to create provider from --db flag

Closes: steveyegge/beads#1196

* test(orphans): add cross-repo and provider tests for --db flag fix

- Add TestFindOrphanedIssues_WithMockProvider (table-driven, UT-01 through UT-09)
- Add TestFindOrphanedIssues_CrossRepo (validates --db flag honored)
- Add TestFindOrphanedIssues_LocalProvider (backward compat RT-01)
- Add TestFindOrphanedIssues_ProviderError (error handling UT-07)
- Add TestFindOrphanedIssues_IntegrationCrossRepo (IT-02 full)
- Add TestLocalProvider_* unit tests

Coverage for IssueProvider interface and cross-repo orphan detection.

* docs: add bd orphans command to CLI reference

Document the orphan detection command including the cross-repo
workflow enabled by the --db flag fix in this PR.
This commit is contained in:
Peter Chanthamynavong
2026-01-21 19:52:31 -08:00
committed by GitHub
parent a0dac11e42
commit c11fa799be
7 changed files with 852 additions and 61 deletions

16
internal/types/orphans.go Normal file
View File

@@ -0,0 +1,16 @@
// Package types defines core data structures for the bd issue tracker.
package types
import "context"
// IssueProvider abstracts issue storage for orphan detection.
// Implementations may be backed by SQLite, RPC, JSONL, or mocks.
type IssueProvider interface {
// GetOpenIssues returns issues that are open or in_progress.
// Should return empty slice (not error) if no issues exist.
GetOpenIssues(ctx context.Context) ([]*Issue, error)
// GetIssuePrefix returns the configured prefix (e.g., "bd", "TEST").
// Should return "bd" as default if not configured.
GetIssuePrefix() string
}