feat(blocked): exclude pinned issues from bd blocked output
- Add Pinned field to Issue struct in types.go - Create migration 023 to add pinned column with partial index - Update SQLite GetBlockedIssues to filter WHERE pinned = 0 - Update Memory GetBlockedIssues to skip pinned issues - Update schema.go with pinned column definition Pinned issues are tracked but excluded from the blocked list to reduce noise for issues that are intentionally parked. Closes: beads-ei4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1063,6 +1063,7 @@ func (m *MemoryStorage) getOpenBlockers(issueID string) []string {
|
||||
}
|
||||
|
||||
// GetBlockedIssues returns issues that are blocked by other issues
|
||||
// Note: Pinned issues are excluded from the output (beads-ei4)
|
||||
func (m *MemoryStorage) GetBlockedIssues(ctx context.Context) ([]*types.BlockedIssue, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
@@ -1075,6 +1076,11 @@ func (m *MemoryStorage) GetBlockedIssues(ctx context.Context) ([]*types.BlockedI
|
||||
continue
|
||||
}
|
||||
|
||||
// Exclude pinned issues (beads-ei4)
|
||||
if issue.Pinned {
|
||||
continue
|
||||
}
|
||||
|
||||
blockers := m.getOpenBlockers(issue.ID)
|
||||
if issue.Status != types.StatusBlocked && len(blockers) == 0 {
|
||||
continue
|
||||
|
||||
@@ -39,6 +39,7 @@ var migrationsList = []Migration{
|
||||
{"edge_consolidation", migrations.MigrateEdgeConsolidation},
|
||||
{"migrate_edge_fields", migrations.MigrateEdgeFields},
|
||||
{"drop_edge_columns", migrations.MigrateDropEdgeColumns},
|
||||
{"pinned_column", migrations.MigratePinnedColumn},
|
||||
}
|
||||
|
||||
// MigrationInfo contains metadata about a migration for inspection
|
||||
@@ -85,6 +86,7 @@ func getMigrationDescription(name string) string {
|
||||
"edge_consolidation": "Adds metadata and thread_id columns to dependencies table for edge schema consolidation (Decision 004)",
|
||||
"migrate_edge_fields": "Migrates existing issue fields (replies_to, relates_to, duplicate_of, superseded_by) to dependency edges (Decision 004 Phase 3)",
|
||||
"drop_edge_columns": "Drops deprecated edge columns (replies_to, relates_to, duplicate_of, superseded_by) from issues table (Decision 004 Phase 4)",
|
||||
"pinned_column": "Adds pinned column to issues table for excluding issues from bd blocked output (beads-ei4)",
|
||||
}
|
||||
|
||||
if desc, ok := descriptions[name]; ok {
|
||||
|
||||
39
internal/storage/sqlite/migrations/023_pinned_column.go
Normal file
39
internal/storage/sqlite/migrations/023_pinned_column.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MigratePinnedColumn adds the pinned column to the issues table.
|
||||
// Pinned issues are excluded from bd blocked output (beads-ei4).
|
||||
func MigratePinnedColumn(db *sql.DB) error {
|
||||
// Check if column exists
|
||||
var columnExists bool
|
||||
err := db.QueryRow(`
|
||||
SELECT COUNT(*) > 0
|
||||
FROM pragma_table_info('issues')
|
||||
WHERE name = 'pinned'
|
||||
`).Scan(&columnExists)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check pinned column: %w", err)
|
||||
}
|
||||
|
||||
if columnExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add pinned column (default false = 0)
|
||||
_, err = db.Exec(`ALTER TABLE issues ADD COLUMN pinned INTEGER DEFAULT 0`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add pinned column: %w", err)
|
||||
}
|
||||
|
||||
// Add partial index for efficient queries on pinned issues
|
||||
_, err = db.Exec(`CREATE INDEX IF NOT EXISTS idx_issues_pinned ON issues(pinned) WHERE pinned = 1`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create pinned index: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -252,11 +252,13 @@ func (s *SQLiteStorage) GetStaleIssues(ctx context.Context, filter types.StaleFi
|
||||
}
|
||||
|
||||
// GetBlockedIssues returns issues that are blocked by dependencies or have status=blocked
|
||||
// Note: Pinned issues are excluded from the output (beads-ei4)
|
||||
func (s *SQLiteStorage) GetBlockedIssues(ctx context.Context) ([]*types.BlockedIssue, error) {
|
||||
// Use UNION to combine:
|
||||
// 1. Issues with open/in_progress/blocked status that have dependency blockers
|
||||
// 2. Issues with status=blocked (even if they have no dependency blockers)
|
||||
// Use GROUP_CONCAT to get all blocker IDs in a single query (no N+1)
|
||||
// Exclude pinned issues (beads-ei4)
|
||||
rows, err := s.db.QueryContext(ctx, `
|
||||
SELECT
|
||||
i.id, i.title, i.description, i.design, i.acceptance_criteria, i.notes,
|
||||
@@ -273,6 +275,7 @@ func (s *SQLiteStorage) GetBlockedIssues(ctx context.Context) ([]*types.BlockedI
|
||||
AND blocker.status IN ('open', 'in_progress', 'blocked')
|
||||
)
|
||||
WHERE i.status IN ('open', 'in_progress', 'blocked')
|
||||
AND i.pinned = 0
|
||||
AND (
|
||||
i.status = 'blocked'
|
||||
OR EXISTS (
|
||||
|
||||
@@ -32,6 +32,8 @@ CREATE TABLE IF NOT EXISTS issues (
|
||||
ephemeral INTEGER DEFAULT 0,
|
||||
-- NOTE: replies_to, relates_to, duplicate_of, superseded_by removed per Decision 004
|
||||
-- These relationships are now stored in the dependencies table
|
||||
-- Workflow fields
|
||||
pinned INTEGER DEFAULT 0,
|
||||
CHECK ((status = 'closed') = (closed_at IS NOT NULL))
|
||||
);
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ type Issue struct {
|
||||
Ephemeral bool `json:"ephemeral,omitempty"` // Can be bulk-deleted when closed
|
||||
// NOTE: RepliesTo, RelatesTo, DuplicateOf, SupersededBy moved to dependencies table
|
||||
// per Decision 004 (Edge Schema Consolidation). Use dependency API instead.
|
||||
|
||||
// Workflow fields
|
||||
Pinned bool `json:"pinned,omitempty"` // Pinned issues are excluded from bd blocked output
|
||||
}
|
||||
|
||||
// ComputeContentHash creates a deterministic hash of the issue's content.
|
||||
|
||||
Reference in New Issue
Block a user