fix(ready): exclude molecule steps from bd ready by default (#1246)

* fix(ready): exclude molecule steps from bd ready by default (GH#1239)

Add ID prefix constants (IDPrefixMol, IDPrefixWisp) to types.go as single
source of truth. Update pour.go and wisp.go to use these constants.

GetReadyWork now excludes issues with -mol- in their ID when no explicit
type filter is specified. Users can still see mol steps with --type=task.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(ready): config-driven ID pattern exclusion (GH#1239)

Add ready.exclude_id_patterns config for excluding IDs from bd ready.
Default patterns: -mol-, -wisp- (molecule steps and wisps).

Changes:
- Add IncludeMolSteps to WorkFilter for internal callers
- Update findGateReadyMolecules and getMoleculeCurrentStep to use it
- Make exclusion patterns config-driven via ready.exclude_id_patterns
- Remove hardcoded MolStepIDPattern() in favor of config
- Add test for custom patterns (e.g., gastown's -role-)

Usage: bd config set ready.exclude_id_patterns "-mol-,-wisp-,-role-"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: remove -role- example from ready.go comments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: remove GH#1239 references from code comments

Issue references belong in commit messages, not code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
aleiby
2026-01-21 19:30:15 -08:00
committed by GitHub
parent 46b1678274
commit 0b6df198a5
9 changed files with 210 additions and 11 deletions

View File

@@ -18,8 +18,7 @@ import (
func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilter) ([]*types.Issue, error) {
whereClauses := []string{
"i.pinned = 0", // Exclude pinned issues
"(i.ephemeral = 0 OR i.ephemeral IS NULL)", // Exclude wisps
"i.id NOT LIKE '%-wisp-%'", // Defense in depth: exclude wisp IDs even if ephemeral flag missing
"(i.ephemeral = 0 OR i.ephemeral IS NULL)", // Exclude wisps by ephemeral flag
}
args := []interface{}{}
@@ -46,6 +45,16 @@ func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilte
// - role: agent role definitions (reference metadata)
// - rig: rig identity beads (reference metadata)
whereClauses = append(whereClauses, "i.issue_type NOT IN ('merge-request', 'gate', 'molecule', 'message', 'agent', 'role', 'rig')")
// Exclude IDs matching configured patterns
// Default patterns: -mol- (molecule steps), -wisp- (ephemeral wisps)
// Configure with: bd config set ready.exclude_id_patterns "-mol-,-wisp-"
// Use --type=task to explicitly include them, or IncludeMolSteps for internal callers
if !filter.IncludeMolSteps {
patterns := s.getExcludeIDPatterns(ctx)
for _, pattern := range patterns {
whereClauses = append(whereClauses, "i.id NOT LIKE '%"+pattern+"%'")
}
}
}
if filter.Priority != nil {
@@ -824,3 +833,35 @@ func buildOrderByClause(policy types.SortPolicy) string {
i.created_at ASC`
}
}
// ExcludeIDPatternsConfigKey is the config key for ID exclusion patterns in GetReadyWork
const ExcludeIDPatternsConfigKey = "ready.exclude_id_patterns"
// DefaultExcludeIDPatterns are the default patterns to exclude from GetReadyWork
// These exclude molecule steps (-mol-) and wisps (-wisp-) which are internal workflow items
var DefaultExcludeIDPatterns = []string{"-mol-", "-wisp-"}
// getExcludeIDPatterns returns the ID patterns to exclude from GetReadyWork.
// Reads from ready.exclude_id_patterns config, defaults to DefaultExcludeIDPatterns.
// Config format: comma-separated patterns, e.g., "-mol-,-wisp-"
func (s *SQLiteStorage) getExcludeIDPatterns(ctx context.Context) []string {
value, err := s.GetConfig(ctx, ExcludeIDPatternsConfigKey)
if err != nil || value == "" {
return DefaultExcludeIDPatterns
}
// Parse comma-separated patterns
parts := strings.Split(value, ",")
patterns := make([]string, 0, len(parts))
for _, p := range parts {
p = strings.TrimSpace(p)
if p != "" {
patterns = append(patterns, p)
}
}
if len(patterns) == 0 {
return DefaultExcludeIDPatterns
}
return patterns
}