feat(search): include closed issues by default (bd-t5yex) (#5392)

* feat(search): include closed issues by default (bd-t5yex)

The dominant real-world search query is 'was this already
found/filed/fixed?' — exactly the query where silently excluding closed
issues produces a false 'no'. Downstream repos grew shell wrappers
(wyvern's bd-find.sh) purely to undo the open-only default; when a repo
writes a wrapper to change a default, the default is probably wrong.

Reverses the hq-319 open-only default on both the embedded and
proxied-server paths. bd list keeps its open-only default. --status open
(etc.) narrows explicitly; --status all still works, now redundantly.

No in-repo programmatic caller depends on the old default (prime/skill
docs mention the command generically; docs/cli-reference regenerates
from the release pin). Changelog note added; embedded + proxied search
suites green including new default_includes_closed coverage both paths.

* fix(search): review fixes — conformance corpus spec, page-eviction + bd-query-divergence docs (bd-t5yex)

Fable adversarial review (FIX_THEN_MERGE) items:
- test/conformance corpus: the search-desc-contains-and-status scenario's
  comment still documented the old closed-exclusion default (the corpus
  comments are the written spec future backends build against), and the
  flip left the scenario with two identical steps — comment updated and
  one step switched to --status open to keep an explicit exclusion probe.
- CHANGELOG + help: document the page-eviction consequence (matches
  beyond --limit are dropped under a status-blind sort; use --status open
  or raise --limit when hunting live work) and that bd query / HTTP q=
  deliberately keep their closed-exclusion default.
This commit is contained in:
Steve Yegge 2026-08-07 00:35:50 -07:00 • committed by GitHub
commit 13ef2948cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 57 additions and 20 deletions

View file

@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- **`bd search` now includes closed issues by default** (bd-t5yex). The
dominant real-world search query is "was this already found/filed/fixed?" —
exactly the query where silently excluding closed issues produced a false
"no" (downstream repos grew shell wrappers purely to undo the old default).
`bd list` keeps its open-only default. Narrow explicitly with `--status open`
(or any status list) where the old behavior is wanted; `--status all` still
works and is now redundant. Applies to both the embedded and proxied-server
paths.
Two consequences to know: matches beyond `--limit` (default 50) are dropped
under a status-blind sort (priority, then created), so a broad query on a
large DB can now fill the page with closed matches and silently drop open
ones — use `--status open` or raise `--limit` when hunting live work. And
`bd query` (plus the HTTP `q=` endpoint) deliberately keeps its closed-
exclusion default with opt-in `--all`; only `bd search` changed.
### Fixed
- **`bd delete --cascade` no longer marks LIVE issues as deleted in other

View file

@ -18,11 +18,14 @@ var searchCmd = &cobra.Command{
Use: "search [query]",
GroupID: "issues",
Short: "Search issues by text query",
Long: `Search issues across title and ID (excludes closed issues by default).
Long: `Search issues across title and ID (all statuses, including closed).
ID-like queries (e.g., "bd-123", "hq-319") use fast exact/prefix matching.
Text queries search titles. Use --desc-contains for description search.
Use --status all to include closed issues.
Use --status open (etc.) to narrow; closed issues are included by default
so "was this already filed/fixed?" cannot silently answer no. Matches
beyond --limit are dropped status-blind, so when hunting live work in a
large DB, narrow with --status open or raise --limit.
Examples:
bd search "authentication bug"
@ -32,7 +35,7 @@ Examples:
bd search "bd-5q" # Search by partial ID (fast prefix match)
bd search "security" --priority-min 0 --priority-max 2
bd search "bug" --created-after 2025-01-01
bd search "refactor" --status all # Include closed issues
bd search "refactor" --status open # Only open issues
bd search "bug" --sort priority
bd search "task" --sort created --reverse
bd search "api" --desc-contains "endpoint"
@ -116,13 +119,13 @@ Examples:
if err := workapi.ApplyStatusFilter(&filter, status, cfg.CustomStatusNames()); err != nil {
return HandleError("%v", err)
}
} else if status != "all" {
// Default: exclude closed issues to reduce scan scope (hq-319).
// With 12K+ issues, ~60-70% are closed — excluding them lets the
// query use the status index to skip the majority of rows.
// Use --status all to search everything including closed.
filter.ExcludeStatus = []types.Status{types.StatusClosed}
}
// Default (no --status) searches ALL statuses including closed
// (bd-t5yex): the dominant real-world query is "was this already
// found/filed/fixed?" — exactly where silently excluding closed
// issues produces a false "no". This reverses the hq-319 open-only
// default, which traded that correctness for scan scope; narrow
// explicitly (e.g. --status open) when performance matters.
if assignee != "" {
filter.Assignee = &assignee
@ -355,7 +358,7 @@ func outputSearchResults(issues []*types.Issue, query string, longFormat bool) {
func init() {
searchCmd.Flags().String("query", "", "Search query (alternative to positional argument)")
searchCmd.Flags().StringP("status", "s", "", "Filter by stored status (comma-separated for OR; open, in_progress, blocked, deferred, closed, all). Default excludes closed; use 'all' to include closed. Note: dependency-blocked issues use 'bd blocked'")
searchCmd.Flags().StringP("status", "s", "", "Filter by stored status (comma-separated for OR; open, in_progress, blocked, deferred, closed, all). Default searches all statuses including closed. Note: dependency-blocked issues use 'bd blocked'")
searchCmd.Flags().StringP("assignee", "a", "", "Filter by assignee")
searchCmd.Flags().StringP("type", "t", "", "Filter by type (bug, feature, task, epic, chore, decision, merge-request, molecule, gate)")
searchCmd.Flags().StringSliceP("label", "l", []string{}, "Filter by labels (AND: must have ALL)")

View file

@ -152,6 +152,19 @@ func TestEmbeddedSearch(t *testing.T) {
}
})
t.Run("search_default_includes_closed", func(t *testing.T) {
// bd-t5yex: "was this already filed/fixed?" is the dominant search
// query, so the default must not silently hide closed issues.
results := bdSearchJSON(t, bd, dir, "sr-")
ids := map[string]bool{}
for _, r := range results {
ids[r["id"].(string)] = true
}
if !ids[taskA.ID] || !ids[closedTask.ID] {
t.Error("expected default search to include open and closed issues")
}
})
t.Run("search_status_comma_separated", func(t *testing.T) {
results := bdSearchJSON(t, bd, dir, "sr-", "--status", "open,closed")
ids := map[string]bool{}

View file

@ -105,9 +105,12 @@ func TestProxiedServerSearch(t *testing.T) {
}
})
t.Run("default_excludes_closed", func(t *testing.T) {
if searchResultIDs(bdProxiedSearchJSON(t, bd, p.dir, "sp-"))[closedTask.ID] {
t.Error("default search should exclude closed issues")
t.Run("default_includes_closed", func(t *testing.T) {
// bd-t5yex: "was this already filed/fixed?" is the dominant search
// query, so the default must not silently hide closed issues.
ids := searchResultIDs(bdProxiedSearchJSON(t, bd, p.dir, "sp-"))
if !ids[taskA.ID] || !ids[closedTask.ID] {
t.Error("default search should include open and closed issues")
}
})

View file

@ -65,9 +65,8 @@ func runSearchProxiedServer(cmd *cobra.Command, ctx context.Context, args []stri
Limit: limit,
}
if status == "" {
filter.ExcludeStatus = []types.Status{types.StatusClosed}
}
// Default (no --status) searches all statuses including closed
// (bd-t5yex) — keep in lockstep with the embedded path in search.go.
if assignee != "" {
filter.Assignee = &assignee

View file

@ -205,16 +205,17 @@ var corpus = []scenario{
{"blocked", "--json"},
}},
// bd search --desc-contains (LOWER(description) LIKE) + default closed-exclusion.
// Lowercase 'endpoint' matches stored 'ENDPOINT' -> [cf-sd1]; plain search hides
// closed cf-sd3 -> []; --status all surfaces it -> [cf-sd3].
// bd search --desc-contains (LOWER(description) LIKE) + status defaulting.
// Lowercase 'endpoint' matches stored 'ENDPOINT' -> [cf-sd1]; plain search
// INCLUDES closed cf-sd3 by default (bd-t5yex) -> [cf-sd3]; --status open
// excludes it -> [].
{name: "search-desc-contains-and-status", steps: [][]string{
{"create", "alpha", "--id", "cf-sd1", "-t", "task", "--description", "Login ENDPOINT here"},
{"create", "gamma", "--id", "cf-sd3", "-t", "task"},
{"close", "cf-sd3"},
{"search", "alpha", "--desc-contains", "endpoint", "--json"},
{"search", "gamma", "--json"},
{"search", "gamma", "--status", "all", "--json"},
{"search", "gamma", "--status", "open", "--json"},
}},
// bd list --parent <id> --flat: non-recursive ParentID filter (deps parent-child