From 5aacff4423505c70b32fef1528b80712774e9507 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 19 Dec 2025 00:47:50 -0800 Subject: [PATCH] feat(ready): exclude pinned issues from bd ready (beads-92u) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/storage/sqlite/dependencies.go | 20 ++++++++-- internal/storage/sqlite/issues.go | 20 +++++++--- internal/storage/sqlite/labels.go | 2 +- internal/storage/sqlite/migrations.go | 2 + .../sqlite/migrations/023_pinned_column.go | 38 +++++++++++++++++++ internal/storage/sqlite/migrations_test.go | 3 +- internal/storage/sqlite/multirepo.go | 14 ++++--- internal/storage/sqlite/queries.go | 22 ++++++++--- internal/storage/sqlite/ready.go | 7 +++- internal/storage/sqlite/schema.go | 2 + internal/storage/sqlite/transaction.go | 12 ++++-- internal/types/types.go | 3 ++ 12 files changed, 118 insertions(+), 27 deletions(-) create mode 100644 internal/storage/sqlite/migrations/023_pinned_column.go diff --git a/internal/storage/sqlite/dependencies.go b/internal/storage/sqlite/dependencies.go index d55543bf..8c6a8fd5 100644 --- a/internal/storage/sqlite/dependencies.go +++ b/internal/storage/sqlite/dependencies.go @@ -233,7 +233,7 @@ func (s *SQLiteStorage) GetDependenciesWithMetadata(ctx context.Context, issueID i.status, i.priority, i.issue_type, i.assignee, i.estimated_minutes, i.created_at, i.updated_at, i.closed_at, i.external_ref, i.source_repo, i.deleted_at, i.deleted_by, i.delete_reason, i.original_type, - i.sender, i.ephemeral, + i.sender, i.ephemeral, i.pinned, d.type FROM issues i JOIN dependencies d ON i.id = d.depends_on_id @@ -255,7 +255,7 @@ func (s *SQLiteStorage) GetDependentsWithMetadata(ctx context.Context, issueID s i.status, i.priority, i.issue_type, i.assignee, i.estimated_minutes, i.created_at, i.updated_at, i.closed_at, i.external_ref, i.source_repo, i.deleted_at, i.deleted_by, i.delete_reason, i.original_type, - i.sender, i.ephemeral, + i.sender, i.ephemeral, i.pinned, d.type FROM issues i JOIN dependencies d ON i.id = d.issue_id @@ -714,6 +714,8 @@ func (s *SQLiteStorage) scanIssues(ctx context.Context, rows *sql.Rows) ([]*type // Messaging fields (bd-kwro) var sender sql.NullString var ephemeral sql.NullInt64 + // Pinned field (bd-92u) + var pinned sql.NullInt64 err := rows.Scan( &issue.ID, &contentHash, &issue.Title, &issue.Description, &issue.Design, @@ -721,7 +723,7 @@ func (s *SQLiteStorage) scanIssues(ctx context.Context, rows *sql.Rows) ([]*type &issue.Priority, &issue.IssueType, &assignee, &estimatedMinutes, &issue.CreatedAt, &issue.UpdatedAt, &closedAt, &externalRef, &sourceRepo, &closeReason, &deletedAt, &deletedBy, &deleteReason, &originalType, - &sender, &ephemeral, + &sender, &ephemeral, &pinned, ) if err != nil { return nil, fmt.Errorf("failed to scan issue: %w", err) @@ -766,6 +768,10 @@ func (s *SQLiteStorage) scanIssues(ctx context.Context, rows *sql.Rows) ([]*type if ephemeral.Valid && ephemeral.Int64 != 0 { issue.Ephemeral = true } + // Pinned field (bd-92u) + if pinned.Valid && pinned.Int64 != 0 { + issue.Pinned = true + } issues = append(issues, &issue) issueIDs = append(issueIDs, issue.ID) @@ -805,6 +811,8 @@ func (s *SQLiteStorage) scanIssuesWithDependencyType(ctx context.Context, rows * // Messaging fields (bd-kwro) var sender sql.NullString var ephemeral sql.NullInt64 + // Pinned field (bd-92u) + var pinned sql.NullInt64 var depType types.DependencyType err := rows.Scan( @@ -813,7 +821,7 @@ func (s *SQLiteStorage) scanIssuesWithDependencyType(ctx context.Context, rows * &issue.Priority, &issue.IssueType, &assignee, &estimatedMinutes, &issue.CreatedAt, &issue.UpdatedAt, &closedAt, &externalRef, &sourceRepo, &deletedAt, &deletedBy, &deleteReason, &originalType, - &sender, &ephemeral, + &sender, &ephemeral, &pinned, &depType, ) if err != nil { @@ -856,6 +864,10 @@ func (s *SQLiteStorage) scanIssuesWithDependencyType(ctx context.Context, rows * 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) diff --git a/internal/storage/sqlite/issues.go b/internal/storage/sqlite/issues.go index 23ec183a..c3e4bcfb 100644 --- a/internal/storage/sqlite/issues.go +++ b/internal/storage/sqlite/issues.go @@ -31,6 +31,10 @@ func insertIssue(ctx context.Context, conn *sql.Conn, issue *types.Issue) error if issue.Ephemeral { ephemeral = 1 } + pinned := 0 + if issue.Pinned { + pinned = 1 + } _, err := conn.ExecContext(ctx, ` INSERT OR IGNORE INTO issues ( @@ -38,8 +42,8 @@ func insertIssue(ctx context.Context, conn *sql.Conn, issue *types.Issue) error 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 - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + sender, ephemeral, pinned + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `, issue.ID, issue.ContentHash, issue.Title, issue.Description, issue.Design, issue.AcceptanceCriteria, issue.Notes, issue.Status, @@ -47,7 +51,7 @@ func insertIssue(ctx context.Context, conn *sql.Conn, issue *types.Issue) error issue.EstimatedMinutes, issue.CreatedAt, issue.UpdatedAt, issue.ClosedAt, issue.ExternalRef, sourceRepo, issue.CloseReason, issue.DeletedAt, issue.DeletedBy, issue.DeleteReason, issue.OriginalType, - issue.Sender, ephemeral, + issue.Sender, ephemeral, pinned, ) if err != nil { // INSERT OR IGNORE should handle duplicates, but driver may still return error @@ -68,8 +72,8 @@ func insertIssues(ctx context.Context, conn *sql.Conn, issues []*types.Issue) er 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 - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + sender, ephemeral, pinned + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `) if err != nil { return fmt.Errorf("failed to prepare statement: %w", err) @@ -86,6 +90,10 @@ func insertIssues(ctx context.Context, conn *sql.Conn, issues []*types.Issue) er if issue.Ephemeral { ephemeral = 1 } + pinned := 0 + if issue.Pinned { + pinned = 1 + } _, err = stmt.ExecContext(ctx, issue.ID, issue.ContentHash, issue.Title, issue.Description, issue.Design, @@ -94,7 +102,7 @@ func insertIssues(ctx context.Context, conn *sql.Conn, issues []*types.Issue) er issue.EstimatedMinutes, issue.CreatedAt, issue.UpdatedAt, issue.ClosedAt, issue.ExternalRef, sourceRepo, issue.CloseReason, issue.DeletedAt, issue.DeletedBy, issue.DeleteReason, issue.OriginalType, - issue.Sender, ephemeral, + issue.Sender, ephemeral, pinned, ) if err != nil { // INSERT OR IGNORE should handle duplicates, but driver may still return error diff --git a/internal/storage/sqlite/labels.go b/internal/storage/sqlite/labels.go index cc11ed3c..c07a20b1 100644 --- a/internal/storage/sqlite/labels.go +++ b/internal/storage/sqlite/labels.go @@ -159,7 +159,7 @@ func (s *SQLiteStorage) GetIssuesByLabel(ctx context.Context, label string) ([]* i.status, i.priority, i.issue_type, i.assignee, i.estimated_minutes, i.created_at, i.updated_at, i.closed_at, i.external_ref, i.source_repo, i.close_reason, i.deleted_at, i.deleted_by, i.delete_reason, i.original_type, - i.sender, i.ephemeral + i.sender, i.ephemeral, i.pinned FROM issues i JOIN labels l ON i.id = l.issue_id WHERE l.label = ? diff --git a/internal/storage/sqlite/migrations.go b/internal/storage/sqlite/migrations.go index b84f6409..30515a8d 100644 --- a/internal/storage/sqlite/migrations.go +++ b/internal/storage/sqlite/migrations.go @@ -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 persistent anchors excluded from bd ready (bd-92u)", } if desc, ok := descriptions[name]; ok { diff --git a/internal/storage/sqlite/migrations/023_pinned_column.go b/internal/storage/sqlite/migrations/023_pinned_column.go new file mode 100644 index 00000000..ff1b0bad --- /dev/null +++ b/internal/storage/sqlite/migrations/023_pinned_column.go @@ -0,0 +1,38 @@ +package migrations + +import ( + "database/sql" + "fmt" +) + +// MigratePinnedColumn adds the pinned column to the issues table. +// Pinned issues are persistent anchors that should be excluded from bd ready (bd-92u). +func MigratePinnedColumn(db *sql.DB) error { + // Check if column already 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 + } + + _, 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 pinned issues (efficient filtering) + _, 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 +} diff --git a/internal/storage/sqlite/migrations_test.go b/internal/storage/sqlite/migrations_test.go index 1e02b3db..c2ac7a66 100644 --- a/internal/storage/sqlite/migrations_test.go +++ b/internal/storage/sqlite/migrations_test.go @@ -489,9 +489,10 @@ func TestMigrateContentHashColumn(t *testing.T) { relates_to TEXT DEFAULT '', duplicate_of TEXT DEFAULT '', superseded_by TEXT DEFAULT '', + pinned INTEGER DEFAULT 0, CHECK ((status = 'closed') = (closed_at IS NOT NULL)) ); - INSERT INTO issues SELECT id, 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, original_size, compacted_at_commit, source_repo, '', NULL, '', '', '', '', 0, '', '', '', '' FROM issues_backup; + INSERT INTO issues SELECT id, 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, original_size, compacted_at_commit, source_repo, '', NULL, '', '', '', '', 0, '', '', '', '', 0 FROM issues_backup; DROP TABLE issues_backup; `) if err != nil { diff --git a/internal/storage/sqlite/multirepo.go b/internal/storage/sqlite/multirepo.go index 8e37c5d4..86861bdb 100644 --- a/internal/storage/sqlite/multirepo.go +++ b/internal/storage/sqlite/multirepo.go @@ -261,6 +261,10 @@ func (s *SQLiteStorage) upsertIssueInTx(ctx context.Context, tx *sql.Tx, issue * if issue.Ephemeral { ephemeral = 1 } + pinned := 0 + if issue.Pinned { + pinned = 1 + } if err == sql.ErrNoRows { // Issue doesn't exist - insert it @@ -270,8 +274,8 @@ func (s *SQLiteStorage) upsertIssueInTx(ctx context.Context, tx *sql.Tx, issue * 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 - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + sender, ephemeral, pinned + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `, issue.ID, issue.ContentHash, issue.Title, issue.Description, issue.Design, issue.AcceptanceCriteria, issue.Notes, issue.Status, @@ -279,7 +283,7 @@ func (s *SQLiteStorage) upsertIssueInTx(ctx context.Context, tx *sql.Tx, issue * issue.EstimatedMinutes, issue.CreatedAt, issue.UpdatedAt, issue.ClosedAt, issue.ExternalRef, issue.SourceRepo, issue.CloseReason, issue.DeletedAt, issue.DeletedBy, issue.DeleteReason, issue.OriginalType, - issue.Sender, ephemeral, + issue.Sender, ephemeral, pinned, ) if err != nil { return fmt.Errorf("failed to insert issue: %w", err) @@ -303,7 +307,7 @@ func (s *SQLiteStorage) upsertIssueInTx(ctx context.Context, tx *sql.Tx, issue * issue_type = ?, assignee = ?, estimated_minutes = ?, updated_at = ?, closed_at = ?, external_ref = ?, source_repo = ?, deleted_at = ?, deleted_by = ?, delete_reason = ?, original_type = ?, - sender = ?, ephemeral = ? + sender = ?, ephemeral = ?, pinned = ? WHERE id = ? `, issue.ContentHash, issue.Title, issue.Description, issue.Design, @@ -311,7 +315,7 @@ func (s *SQLiteStorage) upsertIssueInTx(ctx context.Context, tx *sql.Tx, issue * issue.IssueType, issue.Assignee, issue.EstimatedMinutes, issue.UpdatedAt, issue.ClosedAt, issue.ExternalRef, issue.SourceRepo, issue.DeletedAt, issue.DeletedBy, issue.DeleteReason, issue.OriginalType, - issue.Sender, ephemeral, + issue.Sender, ephemeral, pinned, issue.ID, ) if err != nil { diff --git a/internal/storage/sqlite/queries.go b/internal/storage/sqlite/queries.go index 5939d379..b114fb0a 100644 --- a/internal/storage/sqlite/queries.go +++ b/internal/storage/sqlite/queries.go @@ -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 diff --git a/internal/storage/sqlite/ready.go b/internal/storage/sqlite/ready.go index 17a16b64..b3ff7b64 100644 --- a/internal/storage/sqlite/ready.go +++ b/internal/storage/sqlite/ready.go @@ -12,8 +12,11 @@ import ( // GetReadyWork returns issues with no open blockers // By default, shows both 'open' and 'in_progress' issues so epics/tasks // ready to close are visible (bd-165) +// Excludes pinned issues which are persistent anchors, not actionable work (bd-92u) func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilter) ([]*types.Issue, error) { - whereClauses := []string{} + whereClauses := []string{ + "i.pinned = 0", // Exclude pinned issues (bd-92u) + } args := []interface{}{} // Default to open OR in_progress if not specified (bd-165) @@ -101,7 +104,7 @@ func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilte i.status, i.priority, i.issue_type, i.assignee, i.estimated_minutes, i.created_at, i.updated_at, i.closed_at, i.external_ref, i.source_repo, i.close_reason, i.deleted_at, i.deleted_by, i.delete_reason, i.original_type, - i.sender, i.ephemeral + i.sender, i.ephemeral, i.pinned FROM issues i WHERE %s AND NOT EXISTS ( diff --git a/internal/storage/sqlite/schema.go b/internal/storage/sqlite/schema.go index 750e3c33..99566431 100644 --- a/internal/storage/sqlite/schema.go +++ b/internal/storage/sqlite/schema.go @@ -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 + -- Pinned issues are persistent anchors, excluded from bd ready (bd-92u) + pinned INTEGER DEFAULT 0, CHECK ((status = 'closed') = (closed_at IS NOT NULL)) ); diff --git a/internal/storage/sqlite/transaction.go b/internal/storage/sqlite/transaction.go index abfa933d..b179723f 100644 --- a/internal/storage/sqlite/transaction.go +++ b/internal/storage/sqlite/transaction.go @@ -306,7 +306,7 @@ func (t *sqliteTxStorage) GetIssue(ctx context.Context, id string) (*types.Issue 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) @@ -1098,7 +1098,7 @@ func (t *sqliteTxStorage) SearchIssues(ctx context.Context, query string, filter 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 %s ORDER BY priority ASC, created_at DESC @@ -1141,6 +1141,8 @@ func scanIssueRow(row scanner) (*types.Issue, error) { // Messaging fields (bd-kwro) var sender sql.NullString var ephemeral sql.NullInt64 + // Pinned field (bd-92u) + var pinned sql.NullInt64 err := row.Scan( &issue.ID, &contentHash, &issue.Title, &issue.Description, &issue.Design, @@ -1149,7 +1151,7 @@ func scanIssueRow(row scanner) (*types.Issue, error) { &issue.CreatedAt, &issue.UpdatedAt, &closedAt, &externalRef, &issue.CompactionLevel, &compactedAt, &compactedAtCommit, &originalSize, &sourceRepo, &closeReason, &deletedAt, &deletedBy, &deleteReason, &originalType, - &sender, &ephemeral, + &sender, &ephemeral, &pinned, ) if err != nil { return nil, fmt.Errorf("failed to scan issue: %w", err) @@ -1203,6 +1205,10 @@ func scanIssueRow(row scanner) (*types.Issue, error) { if ephemeral.Valid && ephemeral.Int64 != 0 { issue.Ephemeral = true } + // Pinned field (bd-92u) + if pinned.Valid && pinned.Int64 != 0 { + issue.Pinned = true + } return &issue, nil } diff --git a/internal/types/types.go b/internal/types/types.go index a87c00ea..ffd873f8 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -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. + + // Pinned issues are persistent anchors, excluded from bd ready (bd-92u) + Pinned bool `json:"pinned,omitempty"` } // ComputeContentHash creates a deterministic hash of the issue's content.