feat(ready): exclude pinned issues from bd ready (beads-92u)

Pinned issues are persistent anchors that should not appear in ready
work lists. This adds:

- Pinned bool field to Issue struct
- pinned INTEGER DEFAULT 0 column to schema
- Migration 023 to add pinned column to existing databases
- WHERE i.pinned = 0 filter in GetReadyWork query

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-19 00:47:50 -08:00
parent 9dc34da64a
commit 5aacff4423
12 changed files with 118 additions and 27 deletions

View File

@@ -251,13 +251,15 @@ func (s *SQLiteStorage) GetIssue(ctx context.Context, id string) (*types.Issue,
var contentHash sql.NullString
var compactedAtCommit sql.NullString
// Pinned field (bd-92u)
var pinned sql.NullInt64
err := s.db.QueryRowContext(ctx, `
SELECT id, content_hash, title, description, design, acceptance_criteria, notes,
status, priority, issue_type, assignee, estimated_minutes,
created_at, updated_at, closed_at, external_ref,
compaction_level, compacted_at, compacted_at_commit, original_size, source_repo, close_reason,
deleted_at, deleted_by, delete_reason, original_type,
sender, ephemeral
sender, ephemeral, pinned
FROM issues
WHERE id = ?
`, id).Scan(
@@ -267,7 +269,7 @@ func (s *SQLiteStorage) GetIssue(ctx context.Context, id string) (*types.Issue,
&issue.CreatedAt, &issue.UpdatedAt, &closedAt, &externalRef,
&issue.CompactionLevel, &compactedAt, &compactedAtCommit, &originalSize, &sourceRepo, &closeReason,
&deletedAt, &deletedBy, &deleteReason, &originalType,
&sender, &ephemeral,
&sender, &ephemeral, &pinned,
)
if err == sql.ErrNoRows {
@@ -325,6 +327,10 @@ func (s *SQLiteStorage) GetIssue(ctx context.Context, id string) (*types.Issue,
if ephemeral.Valid && ephemeral.Int64 != 0 {
issue.Ephemeral = true
}
// Pinned field (bd-92u)
if pinned.Valid && pinned.Int64 != 0 {
issue.Pinned = true
}
// Fetch labels for this issue
labels, err := s.GetLabels(ctx, issue.ID)
@@ -431,6 +437,8 @@ func (s *SQLiteStorage) GetIssueByExternalRef(ctx context.Context, externalRef s
// Messaging fields (bd-kwro)
var sender sql.NullString
var ephemeral sql.NullInt64
// Pinned field (bd-92u)
var pinned sql.NullInt64
err := s.db.QueryRowContext(ctx, `
SELECT id, content_hash, title, description, design, acceptance_criteria, notes,
@@ -438,7 +446,7 @@ func (s *SQLiteStorage) GetIssueByExternalRef(ctx context.Context, externalRef s
created_at, updated_at, closed_at, external_ref,
compaction_level, compacted_at, compacted_at_commit, original_size, source_repo, close_reason,
deleted_at, deleted_by, delete_reason, original_type,
sender, ephemeral
sender, ephemeral, pinned
FROM issues
WHERE external_ref = ?
`, externalRef).Scan(
@@ -448,7 +456,7 @@ func (s *SQLiteStorage) GetIssueByExternalRef(ctx context.Context, externalRef s
&issue.CreatedAt, &issue.UpdatedAt, &closedAt, &externalRefCol,
&issue.CompactionLevel, &compactedAt, &compactedAtCommit, &originalSize, &sourceRepo, &closeReason,
&deletedAt, &deletedBy, &deleteReason, &originalType,
&sender, &ephemeral,
&sender, &ephemeral, &pinned,
)
if err == sql.ErrNoRows {
@@ -506,6 +514,10 @@ func (s *SQLiteStorage) GetIssueByExternalRef(ctx context.Context, externalRef s
if ephemeral.Valid && ephemeral.Int64 != 0 {
issue.Ephemeral = true
}
// Pinned field (bd-92u)
if pinned.Valid && pinned.Int64 != 0 {
issue.Pinned = true
}
// Fetch labels for this issue
labels, err := s.GetLabels(ctx, issue.ID)
@@ -1564,7 +1576,7 @@ func (s *SQLiteStorage) SearchIssues(ctx context.Context, query string, filter t
status, priority, issue_type, assignee, estimated_minutes,
created_at, updated_at, closed_at, external_ref, source_repo, close_reason,
deleted_at, deleted_by, delete_reason, original_type,
sender, ephemeral
sender, ephemeral, pinned
FROM issues
%s
ORDER BY priority ASC, created_at DESC