* fix(show): --current through issueops.FindCurrentIssue over the Querier role; no swallowed refusal (S6e)
Over http `bd show --current` printed the WRONG issue, exit 0.
resolveCurrentIssueID asked the raw SearchIssues method for the actor's
in_progress and then hooked work; the http backend refuses that method, the
refusal was taken for "nothing found", and the command fell back to the
last-touched issue. The proxied route had its own copy of the lookup, read
inside its unit of work, with the same swallow.
One library entry now: issueops.FindCurrentIssue(ctx, Querier, actor). It
asks the Querier role (queryIssues over http, which every deployed server
publishes) for `status=<s> AND assignee="<actor>"`, limit 1 — exactly the
raw filter, answered in the store's default order, so the same row comes
first on every backend — in_progress, then hooked. A failed read is an
error; "" (two reads that answered and found nothing) is the only miss. The
actor is a quoted, escaped query value; the query language reads
`assignee=none`/`null` as "unassigned", so such an actor (or an empty one)
is not asked about.
Both CLI routes call it with their route's Querier (store.Querier() or the
proxied provider's) through one cmd/bd helper; what stays in the CLI is the
actor and the last-touched fallback (a workspace file). The proxied route
resolves --current before it opens its unit of work, and its duplicate
in-transaction lookup is deleted.
Tests: issueops unit tests (order, failure is an error on either read,
quoting, unaskable actors, each expression evaluates to exactly the raw
filter); cmd/bd fallback tests; served e2e TestE2E_ShowCurrentOverHTTP
(in-progress beats a later-touched issue, hooked when nothing is in
progress, last-touched only when neither). Against the old code the e2e
fails with exactly the reported bug.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(recompute-blocked): one library entry, storage.RecomputeBlocked; a no-op on a remote backend (S25)
`bd recompute-blocked` refused over http ("storage backend does not support
is_blocked recompute"), and gc's BdStore.RecomputeBlocked issues it.
is_blocked is server-derived. Every write a remote client makes is committed
by the server's own store, which keeps the flag under
issueops.BlockedStateInvariant's local-write clause (targeted, inside the
write's transaction; a Postgres-family server has no full recompute at all
and runs a no-op readiness strategy for the same reason). A client cannot
leave the flag stale and holds no copy of it. The invariant's merge clause
(a recompute skipped after a pull, bd-6dnrw.37; a migration that over-set
it, beads#7037) happens to the SERVER's database, and its repair is this
command in the server's workspace.
So the decision is in the library, not the CLI: storage.RecomputeBlocked
(internal/storage/blocked_recomputer.go) is the one entry every backend goes
through. A local store (storage.BlockedRecomputer) recomputes its column; a
store implementing storage.ServerMaintainedBlockedState — the http client,
whose BlockedStateMaintainedByServer answers true — recomputes nothing and
reports MaintainedBy "server". No wire operation: a whole-column rewrite any
bearer of a workspace credential could trigger, for state no client can have
caused, is not one to publish. The proxied route keeps its pinned-connection
plumbing around the same versioncontrolops body the stores run.
--json keeps rows_corrected (gc requires the member; wh-bridge-sync reads the
exit code) as 0 and adds maintained_by: "server"; the text says where the
repair runs.
Tests: storage unit tests (local repair runs, server-maintained wins even
over a local repair and runs none, neither refuses); served e2e
TestE2E_RecomputeBlockedOverHTTP (exit 0, JSON shape, text, ready set
unchanged). With the server-maintained branch disabled the e2e fails with
the old refusal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(search): every bd search route through Reader.List with issueops.SearchListRequest; listIssues `q` behind issues.list.search (S26)
`bd search` called the raw SearchIssues method with its text, which the http
backend refuses ("partial-id search is not available over HTTP"), and its
direct and proxied routes each mapped the flags onto a storage filter by
hand. No served operation could carry search's meaning (title OR id contains
the text, case-insensitively; an id-shaped text also matches exact id, id
prefix and external ref): TitleSearch is title-only and the query language
has no title-or-id predicate.
The library entry is issueops.Reader.List:
- issueops.ListRequest gains Query, SearchIssues' free-text argument as a
member. Both Reader bodies (workapi/storereader and the uow reader) pass it
to SearchIssuesWithCounts where they passed "". It narrows and lifts no
default exclusion; the ready arm refuses it (readyScopeFields).
- issueops.SearchListRequest(query) is search's scope as a request: Query,
every status (AllFlag), every kind of row (the four Include*), and the
store's default order (SortBy priority), so --limit keeps the rows a raw
read kept.
- CLI: ONE runSearch for the direct, proxied and remote routes. One builder
(searchListRequest) maps the flags onto SearchListRequest; the route only
picks the reader (store.IssueReader() or the proxied provider's).
--sort/--reverse reorder the page as before. search_proxied_server.go and
its hand-built filter are deleted, and search leaves the forbidigo
filter-writing exemption.
- Server: GET /v0/beads/issues decodes `q` into ListRequest.Query and calls
the same Reader role, behind the new issues.list.search behavior token
(spec parameter cites it; additive, no wire_revision bump; apigen and the
wire-shape digest regenerated).
- Client: the encoder maps Query to `q`; httpReader.List refuses a request
carrying Query BEFORE dialing, with ErrUnsupported{Capability:
issues.list.search}, unless the handshake advertises it — never a round
trip an old server would 400, never the unsearched listing passed off as
the search. CapListSearch mirrors the server token. Flags listIssues
publishes nothing for are put on the request so the encoder refuses them
rather than widening the search.
Tests: Reader contract case RunReaderListQueryMatchesTheTitleOrTheID (also
pins SearchListRequest's scope) on all four legs — dolt, embedded dolt, uow,
served http (label-scoped, so the served leg runs it as written); handler
test that `q` reaches the seam as the search text, not TitleSearch; client
tests for `q` and the pre-dial refusal (zero dials); round-trip and
vocabulary gates; TestSearchRoutesAgree runs the same twelve flag sets on
the direct, proxied and remote routes and requires identical answers
(remote is bd serve over the proxied database, so ids and order too); served
e2e TestE2E_SearchOverHTTP. The remote legs skip with the
SearchIssuesWithCounts refusal until S6c's externaldeps reader passthrough is
underneath (loud refusal, never an empty or wrong answer); with S6c
cherry-picked all three routes agree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* build: resync BUILD srcs and the embedded storage shard manifest for S6e/S25/S26
gazelle picks up cmd/bd/show_current.go, cmd/bd/search_remote.go, the three
backend/http e2e files and internal/httpclient/list_search_test.go; the
embedded storage shard manifest gains
TestEmbeddedReaderListQueryMatchesTheTitleOrTheID
(scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration
--write).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* style: gofmt list_show_filter_modes.go (trailing blank line)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(backend/http/corpus): drop the show --current and recompute-blocked marks S6e and S25 retire
With S26 folded in, `bd show --current` resolves through
issueops.FindCurrentIssue over the Querier role and `bd recompute-blocked`
goes through storage.RecomputeBlocked (a no-op on a remote backend), so
gc-show-current and gc-recompute-blocked lose their pending marks.
mc-search stays pending, relabelled S6c+SRV-1: bd search now asks listIssues
with q behind issues.list.search, which the reference server profile does
not advertise, so the client refuses before dialing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(cmd/bd): split the bd search route agreement into the embedded and proxied lanes
TestSearchRoutesAgree skipped unless BEADS_TEST_EMBEDDED_DOLT=1, then ran
its proxied and remote legs only under BEADS_TEST_PROXIED_SERVER=1, and
its name matched neither lane's discovery (TestEmbedded* in
*_embedded_test.go, TestProxiedServer*/TestServerMode*). No CI lane ran
it, which main's #7468 guard (TestProxiedGatedTestsRunInTheProxiedLane)
now fails on.
Split it:
- TestEmbeddedSearchRoutesAgree (search_routes_embedded_test.go): the
direct route, embedded lane.
- TestProxiedServerSearchRoutesAgree (search_routes_proxied_test.go): the
proxied route and the remote route (bd serve over the proxied
workspace), gated only on BEADS_TEST_PROXIED_SERVER. The remote route
must still answer the proxied one row for row, ids and order included,
and refuse the flag listIssues cannot carry.
Neither lane can run the other's workspace, so the shared helper
(search_routes_parity_test.go: the seed, the twelve flag sets, and
checkSearchRoute) holds every route to one expected answer per flag set;
agreeing with it is agreeing with each other. The remote leg's "needs
S6c" skip is gone: S6c is on main, so a refusal now fails.
Both manifests regenerated incrementally (embedded 100-shard block, shard
71; proxied 34-shard block, shard 23). Bazel: bd_embedded_part2_test
(--config=embedded) and bd_proxied_test (--config=doltserver-proxied)
pass and run the new tests; //scripts:go_test_sources_test passes.
Swapping the title-sort expectation fails both routes of the proxied
test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(search): keep an infra type's durable rows, expand --type aliases, fail the S26 e2e on refusal (bd-1ejjv6)
Review fixes for #7528, attempt 1: the three majors and three minors of
the synthesis.
`bd search --type <infra type>` dropped the type's durable rows (a
promoted wisp, an issue retyped after it was created), exit 0. The shared
listing (workapi.BuildListFilter) narrowed an infra --type to its
ephemeral rows unconditionally, so SearchListRequest's IncludeEphemeral
did not bring back what raw SearchIssues used to return. The narrowing
now applies only without IncludeEphemeral, in BuildListFilter and in the
count lockstep (applyCountIncludeInfra), and the http parent-walk
recognizer reads an infra type's Ephemeral back as the include_ephemeral
intent. This also fixes `bd list --type <infra type> --include-ephemeral`
and GET /v0/beads/issues, which shipped the narrowing in v1.3.1. Pinned by
workapi tests and by template, gate, wisp and promoted-message rows in the
Reader conformance Query case (new ReaderFixture.PromoteWisp) on the
dolt, embedded, uow and served backends; the issueops Reader/Counter docs
and the openapi descriptions say the same.
`bd search --type` handed the raw string to the Reader: an alias (feat,
mol, mr, ...) answered nothing and an unknown type an empty result. It is
now expanded with utils.NormalizeIssueType as `bd list` does, and an
unknown type exits 1. The help text and the CHANGELOG say so, and the
CHANGELOG also records the additive comments_omitted field in
`bd search --json` rows.
TestE2E_SearchOverHTTP skipped on the very SearchIssuesWithCounts refusal
it exists to catch; it now fails. The route agreement seeds "kinded"
template, gate, wisp and promoted-message rows and pins the alias, the
unknown-type refusal and the infra rows on the direct, proxied and remote
routes.
Minors: the CHANGELOG states the proxied `bd show --current` miss
fallback; the CommentsOmitted contract names `bd search --json`; the
storage.RecomputeBlocked and `bd recompute-blocked` comments name the
deliberate --proxied-server bypass.
Validation: go vet and gofmt on every changed package; make api-check;
workapi, issueops, httpclient/encode, types and storage unit tests; the
Reader conformance on dolt, embedded, uow and served; the embedded and
proxied route agreements (remote included), the embedded search tests,
TestProxiedServerSearch, TestProxiedServerRecomputeBlocked, the http e2e
search/show/recompute tests; docs flag, freshness and docsync checks; and
a hand-run bd search/list/count against a scratch workspace.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.5 KiB
Go
64 lines
2.5 KiB
Go
package issueops
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// CurrentIssueStatuses is the order FindCurrentIssue looks in: the actor's
|
|
// in-progress work first, then work hooked to it.
|
|
var CurrentIssueStatuses = []types.Status{types.StatusInProgress, types.StatusHooked}
|
|
|
|
// FindCurrentIssue answers `bd show --current`'s question — which issue is
|
|
// this actor working on — through the Querier role, which every backend
|
|
// serves (a remote one as queryIssues). It returns the id of the first issue
|
|
// in the actor's in-progress work, else the first hooked to it, in the store's
|
|
// default order; "" when both reads answered and found nothing.
|
|
//
|
|
// A FAILED READ IS AN ERROR, never a miss. A caller falls back (to the
|
|
// last-touched issue, say) only on "", which only two reads that answered can
|
|
// produce. Treating a refusal as "nothing in progress" is what made the http
|
|
// backend print the wrong issue with exit 0.
|
|
//
|
|
// Each read is exactly the filter `status=<s>`, `assignee=<actor>` and nothing
|
|
// else, one row. The actor travels as a quoted query value. The query language
|
|
// reads `assignee=none` and `assignee=null` (any case) as "no assignee", so an
|
|
// actor by one of those names, or an empty actor, cannot be asked about and
|
|
// gets "".
|
|
func FindCurrentIssue(ctx context.Context, querier Querier, actor string) (string, error) {
|
|
if querier == nil || actor == "" || strings.EqualFold(actor, "none") || strings.EqualFold(actor, "null") {
|
|
return "", nil
|
|
}
|
|
for _, status := range CurrentIssueStatuses {
|
|
page, err := querier.Query(ctx, currentIssueQuery(status, actor))
|
|
if err != nil {
|
|
return "", fmt.Errorf("finding the current issue (%s, assigned to %s): %w", status, actor, err)
|
|
}
|
|
for _, row := range page.Items {
|
|
if row != nil && row.Issue != nil {
|
|
return row.ID, nil
|
|
}
|
|
}
|
|
}
|
|
return "", nil
|
|
}
|
|
|
|
// currentIssueQuery is the role request for one status. No display order:
|
|
// every backend answers in its default order, and a sort would change which
|
|
// row is "current".
|
|
func currentIssueQuery(status types.Status, actor string) QueryRequest {
|
|
one := 1
|
|
return QueryRequest{
|
|
Expression: fmt.Sprintf("status=%s AND assignee=%s", status, quoteQueryValue(actor)),
|
|
Limit: &one,
|
|
}
|
|
}
|
|
|
|
// quoteQueryValue renders v as a double-quoted query-language string, escaping
|
|
// the two characters the lexer gives meaning inside one.
|
|
func quoteQueryValue(v string) string {
|
|
return `"` + strings.NewReplacer(`\`, `\\`, `"`, `\"`).Replace(v) + `"`
|
|
}
|